<feed xmlns='http://www.w3.org/2005/Atom'>
<title>generate-image-sd15-mcp.git/src/mcp_sd15/schema.py, branch main</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=main</id>
<link rel='self' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.takashi-2521.com/generate-image-sd15-mcp.git/'/>
<updated>2026-09-12T12:19:16+00:00</updated>
<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>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>
