Skip to main content
Glama
m-rocafort

week7-mcp-server

by m-rocafort

第7週 — MCP(エージェントに専用ツールを持たせる、標準的な方法)

分野全体がAIへとシフトする中で、自動化スキルを磨いていく旅の一部です。今週のテーマは Model Context Protocol (MCP) です。プロンプトにデータを貼り付ける代わりに、LLMには小さなツール群が手渡され、質問に答えるためにどのツールをどの順番で呼び出すかを、モデル自身が決定します。

今週が重要な理由: プロンプトにデータをハードコードするやり方は、デモを超えてはスケールしません。MCPは「ここにあなたのツールとデータソースがあります。あとはどうぞ」というための新たな標準であり、エージェントをスナップショットではなくライブなシステムに接続することを可能にします。

アーキテクチャ

[client.py asks a question]
            |
            v
[Claude sees 3 tool definitions — no invoice data in the prompt]
            |  decides which tools to call, with what arguments
            v
[MCP server (server.py): list_invoices / get_invoice / get_purchase_order]
            |  returns live data over stdio
            v
[Claude reasons over the results and answers]

連続性: 第2週では文書から請求書を抽出しました。第6週では、ボットがすでに手にしていたデータを基に、請求書の例外をどう処理するかを決定しました。今週では、データ自体がMCPサーバーの背後に存在し、エージェントはデータを与えられるのではなく、自分自身で事実を取得します。これを第6週のポリシーガード付き判定サービスと組み合わせると、ロードマップ上のPortfolio Project #4、つまり情報を調べると同時に、判定を監査可能なルール層に委ねるエージェントが実現します。

Related MCP server: Invoice MCP Server

このリポジトリの内容

ファイル

役割

src/server.py

MCPサーバー — list_invoicesget_invoiceget_purchase_order を公開する

src/client.py

サーバーを起動し、Claudeから直接操作する — 個別のサーバープロセスの起動は不要

tests/test_server_tools.py

ツール関数の単体テスト — APIキーは不要

1. 実行する

python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
# copy .env.example to .env and paste your key

python src/client.py

client.pyはstdio経由でserver.py自体を起動します(これはローカルツールのMCPの標準的な動作であり、第6週とは異なりHTTPポートを管理する必要はありません)。Claudeが何を調べる必要があるかを判断する際に、[MCP tool call: ...]という行が表示されるのを確認してください。

ツールロジックの単体テストを実行します(APIキーは不要):

pytest

2. 核となる設計アイデア: 標準プロトコルによるツールとデータ

MCP以前は、モデルにツールを与えるというのは、プロジェクトごとにJSONスキーマとディスパッチ用のif/elifを手作りすることを意味していました。MCPはそれを標準化します。server.py@mcp.tool()でツールを一度宣言し、任意の MCP対応クライアント(このリポジトリのclient.py、Claude Desktop、別のチームのエージェント)が同じ方法でツールを発見し呼び出せます。これが「エージェントを実際のツールに接続する」という提案です。ツール提供者とエージェントは、同じ人が作る必要はありません。

3. 学んだこと / 本番運用に対応しているかどうか

  • MCPは、データを所有する者データについて推論する者を分離します。サーバーが呼び出しているのはどのLLMでもよく、知る必要も、気にする必要もありません。

  • モデルの選択もここでは重要です。これは難しい判断ではなくオーケストレーション(どのツールを呼ぶかの決定)なので、安くて速いモデル(claude-haiku-4-5)が正しい選択です。Opus相当の推論は、第6週が行うような判断のために取っておきましょう。

  • 本番運用には対応していません: 「ERP」はインメモリのdictであり、サーバーには認証も、実際のMCPリソースもありません(ツールのみ)。本番バージョンでは、請求書レコードをMCPリソースとしても公開するでしょう(第8週以降)。

技術スタック

Python · MCP(公式Python SDK) · Claude(ツール駆動にclaude-haiku-4-5) · Anthropic SDK · pytest

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    B
    quality
    B
    maintenance
    Bridges to a simple_invoicing FastAPI backend, exposing invoice, product, ledger, inventory, buyer, and payment management as MCP tools for use with MCP-compatible clients.
    15
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables agents to generate, track, and manage invoices via MCP tools, with CLI support for payment tracking and earnings summaries.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A lightweight, local inventory-intelligence MCP server that enables querying structured inventory schemas with read-only, zero-config tools for stock levels, velocity metrics, and purchase orders.
    10
    MIT

View all related MCP servers

Related MCP Connectors

  • A paid remote MCP for CLI tool MCP, built to return verdicts, receipts, usage logs, and audit-ready

  • Hosted MCP server for Mini Accountant: invoices, expenses, customers, analytics, tax estimates.

  • A paid remote MCP for hosted MCP server, built to return verdicts, receipts, usage logs, and audit-r

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/m-rocafort/week7-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server