<feed xmlns='http://www.w3.org/2005/Atom'>
<title>generate-image-sd15-mcp.git/config.example.toml, branch v0.1.0</title>
<subtitle>MCP tool for image generation used stable diffusion 1.5.
</subtitle>
<id>https://git.takashi-2521.com/generate-image-sd15-mcp.git/atom?h=v0.1.0</id>
<link rel='self' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/atom?h=v0.1.0'/>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/'/>
<updated>2026-09-12T14:36:33+00:00</updated>
<entry>
<title>sd_embed導入による長文プロンプト・重み付きプロンプト対応</title>
<updated>2026-09-12T14:36:33+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-09-12T14:36:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/commit/?id=de44625e3baae4d43ad096248b7096578b11e0b0'/>
<id>urn:sha1:de44625e3baae4d43ad096248b7096578b11e0b0</id>
<content type='text'>
SD1.5の77 token制限を回避するため、sd_embedを用いたprompt_embedsベースの
入力方式に変更した。あわせてclip_skipとpad_last_blockの設定を追加した。

sd_embedのget_weighted_text_embeddings_sd15()でpositive/negativeの
プロンプト埋め込みを同時生成し、pipeline呼び出し時にprompt_embeds/
negative_prompt_embedsを渡す。prompt/negative_promptは同時に渡さない。
LoRAロード後にembedding生成を行うため、text encoder LoRAが反映された
状態で埋め込みが作られる。

sd_embedはcommit hash 4a47f71150で固定し、VCS dependencyとして追加。
hatchlingのallow-direct-referencesを有効化。

変更内容:
- pyproject.toml: sd-embed @ git+...@4a47f71150追加、
  allow-direct-references=true
- config.py: GenerationConfigにclip_skip=0, pad_last_block=False追加、
  load_configで[generation]のclip_skip/pad_last_block読込・validation
  (clip_skip: 0-12のinteger, pad_last_block: boolean)
- model_manager.py: 3つのpipeline呼び出しをprompt/negative_promptから
  prompt_embeds/negative_prompt_embedsに変更、_embed_prompts()メソッド追加
- tests/test_config.py: clip_skip/pad_last_blockの正常系・異常系テスト追加
- doc/config.md: [generation]セクションにclip_skip/pad_last_block説明追記、
  設定項目一覧表更新
- config.example.toml: clip_skip/pad_last_blockコメント例追記
- doc/Design.md: GenerationConfigにclip_skip/pad_last_block追記
- README.md: sd_embedの説明追記
- uv.lock: sd_embedおよび依存パッケージ追加

検証:
- ruff format/check、pyright 0 errors、pytest 67 passed
- 実GPU・実モデルで確認:
  - 短いプロンプト: 生成成功
  - 77 token超の長文プロンプト(122 token): 生成成功
  - 重み付きプロンプト(word:1.5)((word)): 生成成功
  - LoRA(pixelartV3) + sd_embed + 重み付き: 生成成功
  - negative promptの重み付き埋め込み: 生成成功
</content>
</entry>
<entry>
<title>base prompt結合機能を追加</title>
<updated>2026-09-12T12:19:16+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-09-12T12:19:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/commit/?id=796251e5b0da524584c9e81b8ad6e1dcc0931aa3'/>
<id>urn:sha1:796251e5b0da524584c9e81b8ad6e1dcc0931aa3</id>
<content type='text'>
config.tomlの[prompt]でpositive/negativeのbase promptファイルを指定し、
MCP経由でLLMから渡されたプロンプトと結合してpipelineへ渡す機能を追加する。
プロンプトファイルは&lt;root&gt;/prompts/&lt;file&gt;に固定し、TOMLにはファイル名のみ
指定する。モデルパスと同じ方針でパストラバーサルを拒否する。

結合方式:
- positive: base_positive, user_positive の順でカンマ区切り
- negative: base_negative\nuser_negative の順で改行区切り
- baseが空の場合はuserプロンプトのみ（後方互換）
- [prompt]省略時はbase promptなし（後方互換）

結合場所はschema.pyのTextToImageRequest.create()に集約し、GuidedImageRequest
とInpaintImageRequestは内部でTextToImageRequest.create()を呼ぶため1箇所の
変更で3ツールすべてに適用される。MCP Tool入力にはbase promptを公開しない。

変更内容:
- config.py: PromptConfig dataclass、AppConfig.promptフィールド、
  _read_promptヘルパー、load_configの[prompt]読込・validation追加。
  positive_file/negative_fileはファイル名のみ受け付け、&lt;root&gt;/prompts/へ解決
- schema.py: _combineヘルパー、TextToImageRequest.create()に
  base_positive/base_negative引数追加、GuidedImageRequest.create()と
  InpaintImageRequest.create()から転送
- tools/generate_image.py: service.config.promptからbaseを取りcreate()へ渡す
- tools/generate_guided_image.py: 同上
- tools/inpaint_image.py: 同上
- tests/conftest.py: app_config fixtureにprompt=PromptConfig()追加
- tests/test_config.py: [prompt]の正常系・異常系テスト追加
  (省略時空、ファイル読込、パストラバーサル拒否、ファイル不存在、positiveのみ)
- tests/test_schema.py: 結合ロジックのテスト追加
  (base両方、positiveのみ、negativeのみ、base空、guided/inpaint転送)
- doc/config.md: §10 [prompt]セクション追記、設定項目一覧表・ディレクトリ構成・
  全設定例更新、既存セクション番号を§11〜§13へ繰り下げ
- config.example.toml: [prompt]コメント例追記
- doc/Specifications.md: モデル構成表にBase prompt行追加、推奨ディレクトリに
  prompts/追記、設定例更新
- doc/Design.md: 設定オブジェクトにPromptConfig追記、モデルパス解決表に
  prompts/追加
- doc/mcp.md: §2.1にbase prompt結合の記載追記
- README.md: [prompt]設定例と結合規則の説明追記

検証:
- ruff format/check、pyright 0 errors、pytest 61 passed
- 実GPU・実モデルでstreamable-http経由generate_imageでbase prompt結合を確認
  positive='masterpiece, best quality, ..., sharp focus, a small red cube on a white table'
  negative='low quality, ..., jpeg artifacts\nnoise'
  base前置・user後置の結合順序が仕様通り機能することをサーバログで検証済み
</content>
</entry>
<entry>
<title>streamable-httpトランスポート対応を追加</title>
<updated>2026-09-12T11:40:07+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-09-12T11:40:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/commit/?id=4f3f548b1b55d4c7477250fc3373b3bd6d0d397f'/>
<id>urn:sha1:4f3f548b1b55d4c7477250fc3373b3bd6d0d397f</id>
<content type='text'>
MCP SDK 2.xのMCPServer.run(transport="streamable-http")を使い、stdioに
加えてStreamable HTTPトランスポートで起動できるようにする。SSEはMCP仕様で
非推奨のため選択肢から除外し、transport enumはstdioとstreamable-httpの
2種類のみとした。

transportの選択はTOML [server] tableで指定し、CLI引数は追加しない。
仕様の「CLI上書きを行わない」「TOML集約」原則に準拠する。[server]省略時は
stdio（後方互換）、streamable-http時はhost=127.0.0.1 port=8000を既定値とする。

変更内容:
- config.py: ServerConfig dataclass、VALID_TRANSPORTS定数、AppConfig.server
  フィールド、load_configの[server]読込・validation追加
- cli.py: main()でconfig.server.transportに応じたrun()引数分岐
- tests/conftest.py: app_config fixtureにserver=ServerConfig()追加
- tests/test_config.py: [server]の正常系・異常系・境界値テスト追加
  (省略時stdio既定値、streamable-http読込、sse/http/ws/unknown拒否、
   port境界値0/65536/-1/文字列、host空文字拒否)
- doc/config.md: [server]セクション追記、設定項目一覧表更新
- config.example.toml: [server]コメント例追記
- doc/Specifications.md: スコープ表にMCPトランスポート行追加
- doc/Design.md: 責務表と起動フロー更新
- doc/mcp.md: 概要のtransport記載更新
- README.md: streamable-http起動例追記
- script/smoke_streamable_http.py: streamable-http経由の検証スクリプト追加

検証:
- ruff format/check、pyright 0 errors、pytest 50 passed
- 実GPU・実モデルでstreamable-http経由generate_imageの全ルート確認
  (HTTP接続→MCP initialize→tools/list→tools/call→PNG生成・返却)
- 生成結果: 335KB PNG、512x512、20 steps、CFG 7.0
</content>
</entry>
<entry>
<title>feat: SD 1.x向けScheduler対応を5種類に整理</title>
<updated>2026-09-12T11:12:17+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-09-12T11:12:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/commit/?id=fd987cb31fd20483080f8d80ce35b53f101f243f'/>
<id>urn:sha1:fd987cb31fd20483080f8d80ce35b53f101f243f</id>
<content type='text'>
generation.schedulerの正式対応値をdpmpp_2m_karras、dpmpp_2m_sde_karras、euler_a、ddim、lcmに限定し、既定値をdpmpp_2m_karrasへ変更する。旧dpmpp_2m、eulerおよび未知値は起動時の設定validationで拒否する。

Scheduler生成処理をPipelineFactoryへ集約する。DPM++ 2M系はDPMSolverMultistepSchedulerを共用し、algorithm_type、solver_order=2、use_karras_sigmas=Trueで通常版とSDE版を切り替える。Euler Ancestral、DDIM、LCMは現在のpipeline scheduler configを引き継いで構築する。

LCM-LoRAは既存のmodel.lora設定から通常のLoRAとして読み込み、LCM選択時にもstepsとcfg_scaleを自動調整せずTOML値をそのまま使用する。MCP Tool schemaにはscheduler入力を追加しない。

Specifications.md、Design.md、config.mdおよびconfig.example.tomlのenum、既定値、対応表、設定例を新仕様へ統一する。5 schedulerの変換、DPM++ constructor option、旧値と未知値の拒否、省略時の既定値、MCP schema非公開をテストで検証する。

検証: ruff check、ruff format --check、pyright、pytest（39 passed）、インストール済みDiffusersで5 schedulerの実インスタンス構築を確認。
</content>
</entry>
<entry>
<title>feat: Stable Diffusion 1.x MCPサーバを実装</title>
<updated>2026-09-12T09:04:56+00:00</updated>
<author>
<name>tanaka takashi</name>
<email>isazaka@gmail.com</email>
</author>
<published>2026-09-12T09:04:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/commit/?id=cba15a62829a0fe57a03c8031f981e8f790e2efc'/>
<id>urn:sha1:cba15a62829a0fe57a03c8031f981e8f790e2efc</id>
<content type='text'>
仕様書・設計書に基づき、ローカルCUDA GPU上のStable Diffusion 1.x互換モデルをMCP経由で利用するサーバを新規実装。

実装内容:
- generate_image、generate_guided_image、inpaint_imageの3ツールをMCP SDK v2で公開
- TOMLからcheckpoint、VAE、複数LoRAと重み、ControlNet、生成設定を読み込み
- モデル種別ごとの固定ディレクトリ解決と起動時の設定・ファイル存在検証を追加
- Depth/MiDaS、OpenPose body/full、ControlNet Inpaintの前処理とパイプライン切替を実装
- FP16/CUDA、1枚固定生成、ControlNetオンデマンドロード、単一GPU直列実行を実装
- Base64 PNG/JPEG入力の形式・サイズ検証と任意のdata URI入力に対応
- seed、サイズ、モード、時刻、処理時間をPNG metadataへ記録
- 任意のローカルPNG保存、生成エラー分類、CUDA OOM後のキャッシュ回復を追加
- --configと--versionを備えたstdio CLIエントリポイントを追加

開発・運用:
- Python 3.11およびuvによる依存・lock管理を構成
- config.example.tomlとセットアップ・運用手順をREADMEへ追加
- Ruff、Pyright、pytestの設定を追加
- 設定、パス解決、schema、画像検証、サービスルーティング、排他制御、MCP画像返却をテスト

検証結果:
- pytest: 30 passed
- Ruff lint/format: passed
- Pyright: 0 errors, 0 warnings
- CLI versionおよびMCPクライアント経由のPNG返却を確認
- 実GPU smoke testはCUDA GPUとモデルファイルがないため対象外
</content>
</entry>
</feed>
