Waigaya
No description available
Ask AI about Waigaya
Powered by Claude · Grounded in docs
I know everything about Waigaya. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
MCP Server Setup
このプロジェクトでは、Python 3.10環境でuvパッケージを使用するDockerコンテナを立ち上げます。以下の手順に従って、環境をセットアップしてください。
必要条件
- Docker
- Docker Compose
セットアップ手順
-
リポジトリをクローンまたはダウンロード
プロジェクトのルートディレクトリに移動します。
-
ディレクトリ構造
プロジェクトのルートディレクトリに
ky_mcpディレクトリを作成します。このディレクトリはコンテナ内の/ky_mcpにマウントされます。mkdir ky_mcp -
Dockerfileの確認
Dockerfileは以下の内容になっています。FROM python:3.10 # 作業ディレクトリを設定 WORKDIR /ky_mcp # 必要なパッケージをインストール RUN pip install uv # コンテナが終了しないようにするためのコマンド CMD ["tail", "-f", "/dev/null"] -
docker-compose.ymlの確認
docker-compose.ymlは以下の内容になっています。version: '3.8' services: mcp_server: build: context: . dockerfile: Dockerfile container_name: ky_mcp volumes: - ./ky_mcp:/ky_mcp -
コンテナの立ち上げ
以下のコマンドを実行して、コンテナを立ち上げます。
docker-compose up -d-dオプションを使用することで、コンテナをバックグラウンドで実行します。 -
コンテナに入る
コンテナ入るには、以下のコマンドを使用します。
docker exec -it ky_mcp bashky_mcpという名前のコンテナにはいることができれば成功です -
MCPサーバーの作成
uvx create-mcp-serverコマンドを使用して、MCPサーバーを作成します。以下のコマンドを実行してください。uvx create-mcp-server --path .このコマンドは、
test_mcpディレクトリにMCPサーバーの基本的な構造を作成します。 -
ちょっとだけいじります claude desctopからdocker内のコードを実行するためにちょいと調整(正しいかは不明) server.pyの一番下にコードを追加します
if __name__ == "__main__": import asyncio asyncio.run(main()) -
クライアントへの設定追加 claude desktopの人は以下のようにいじります。 設定 > 開発者 > 構成を編集
{ "mcpServers": { "test_mcp": { "command": "docker", "args": [ "compose", "-f", "絶対パス/docker-compose.yml", "exec", "-i", "mcp_server", "uv", "run", "src/test_mcp/server.py" ] } } } -
いじってみよう
10-1. Resourceをいじってみよう
例えばこんな感じ
notes: dict[str, str] = {"hirata": "hard"}
server = Server("test_mcp")
@server.list_resources()
async def handle_list_resources() -> list[types.Resource]:
"""
List available note resources.
Each note is exposed as a resource with a custom note:// URI scheme.
"""
return [
types.Resource(
uri=AnyUrl(f"note://internal/hirata"),
name=f"Note: これが平田の説明書",
description=f"私はラーメン二郎が好きです",
mimeType="text/plain",
)
]
10-2. toolをいじってみよう noteの一覧を取得するtoolが無いようなので、作成してみましょう。
修正箇所
- @server.list_tools()以下にツールの説明を追加
- ツール実装箇所をちょいと修正
@server.call_tool()
async def handle_call_tool(
name: str, arguments: dict | None
) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
"""
Handle tool execution requests.
Tools can modify server state and notify clients of changes.
"""
if not name in ("add-note"):
raise ValueError(f"Unknown tool: {name}")
if name == "add-note":
if not arguments:
raise ValueError("Missing arguments")
note_name = arguments.get("name")
content = arguments.get("content")
if not note_name or not content:
raise ValueError("Missing name or content")
# Update server state
notes[note_name] = content
# Notify clients that resources have changed
await server.request_context.session.send_resource_list_changed()
return [
types.TextContent(
type="text",
text=f"Added note '{note_name}' with content: {content}",
)
]
# ここにlist-notesを作成してみましょう
