Skip to main content
Glama
MCP Hackathon Server

MCP Hackathon Server

Official
by GSA-TTS

GSA MCP ハッカソン — サーバーテンプレート

Python で Model Context Protocol (MCP) サーバーを構築するためのすぐに使えるスターターで、IBM Cloud (watsonx Orchestrate) と Databricks 用のデプロイメントキットも含まれています。

FastMCP と uv で構築されています。MCP サーバーを構築したことがない場合は、QUICKSTART.md から始めてください。


MCP サーバーとは?

MCP サーバーは、ツール(モデルが呼び出せる関数)、プロンプト(再利用可能な会話のきっかけ)、リソース(モデルが読み取れるデータ)を、Claude Desktop、Claude Code、または watsonx Orchestrate のようなエージェントプラットフォームなどの AI クライアントに公開します。ツールを記述するのはあなたで、クライアントのモデルがいつ呼び出すかを決定します。

このテンプレートには、それぞれの例が1つずつ含まれた動作するサーバーが用意されているので、例を独自のサービスに置き換えてデプロイできます。


Related MCP server: Python MCP Server Template

リポジトリ構成

mcp-hackathon-template/
├── README.md                  # This file
├── QUICKSTART.md              # 5-minute clone → run → connect walkthrough
├── main.py                    # Local entry point (uv run python main.py)
├── pyproject.toml             # Package + dependencies (uv)
├── requirements.txt           # Mirror of runtime deps (for buildpack hosts)
├── Dockerfile                 # Container image (streamable-HTTP, port 8080)
├── manifest.yaml              # cloud.gov (Cloud Foundry) deploy
├── server.json                # MCP registry metadata
├── .env.example               # Copy to .env for local dev
├── .github/workflows/ci.yml   # Lint + test on push/PR
├── src/
│   └── example_server/        # ← rename to your service
│       ├── app.py             # Thin entry point: builds FastMCP, picks transport
│       ├── config.py          # Settings from env vars / .env
│       ├── models.py          # Pydantic models & enums for tool params
│       ├── utils.py           # Shared helpers (HTTP client, pagination)
│       ├── routes.py          # HTTP-only routes (/health, /version)
│       ├── tools/             # ONE FILE PER TOOL
│       │   ├── __init__.py    #   register_tools(mcp) aggregator
│       │   └── example_tool.py
│       ├── prompts/
│       │   ├── __init__.py    #   register_prompts(mcp) aggregator
│       │   └── example.py
│       └── resources/
│           ├── __init__.py    #   register_resources(mcp) aggregator
│           └── example.py
├── tests/                     # Import + registration smoke tests
├── eval/                      # Stub → build a Phoenix eval harness (see mcp-eval skill)
└── deploy/
    ├── README.md              # Which deployment kit to use
    ├── ibm/                   # watsonx Orchestrate: 3 kits (see below)
    └── databricks/            # Databricks Apps kit

はじめに

前提条件

  • uv — pip install uv または brew install uv

インストールと実行

cp .env.example .env
uv sync
uv run python main.py

サーバーは stdio モードで起動します。これは stdin/stdout を介して JSON-RPC をやり取りするもので、ローカルクライアント(Claude Desktop、Claude Code)がサーバーを起動する方法です。クライアントを接続するには QUICKSTART.md を参照してください。

確認

uv sync --group dev
uv run pytest tests/ -v      # tests
uv run ruff check .          # lint

1ファイルに1ツールのパターン

各ツールは src/example_server/tools/ の下の独自のファイルに置かれ、register(mcp) 関数を公開します。tools/__init__.py は単一の register_tools(mcp) から各ツールを呼び出します。これにより、ツールリストをスキャンしやすくし、2つのファイルに触れるだけで統合を追加または削除できます。

ステップ1 — src/example_server/tools/my_tool.py を作成:

from typing import Annotated
from fastmcp import FastMCP

from example_server.utils import fetch_json


def register(mcp: FastMCP) -> None:
    @mcp.tool(
        name="example_get_thing",
        annotations={
            "title": "Get a thing",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True,
        },
    )
    async def get_thing(thing_id: Annotated[str, "The ID to fetch."]) -> dict:
        """One-line summary. Document the data source, its update cadence,
        and the return shape here — the model reads this docstring."""
        return await fetch_json(f"https://api.example.gov/things/{thing_id}")

ステップ2 — tools/__init__.py で配線:

from example_server.tools import example_tool, my_tool

def register_tools(mcp) -> None:
    example_tool.register(mcp)
    my_tool.register(mcp)  # ← add this line

ステップ3 — API キーを追加 config.py の型付きフィールドとして追加し、.env.example に環境変数を記載します。

プロンプト(prompts/)とリソース(resources/)も、まったく同じ register(mcp) + アグリゲーターパターンに従います。


パッケージ名の変更

サーバーを公開する前に、example_server を自分のサービス(例: census_mcp)に変更します:

  1. フォルダ src/example_server/ を src/<your_name>/ に変更します。

  2. pyproject.toml の [project].name、[project.scripts]、[tool.hatch.build.targets.wheel].packages を更新します。

  3. src/、tests/、main.py、Dockerfile、manifest.yaml 全体で example_server を検索して置換します。


ツール設計のヒント(連邦データ)

  • 散文ではなく構造化データを返す。 一貫したキーを持つ dict やリストを返し、モデルに説明させます。

  • 鮮度を文書化する。 連邦データセットは遅延があります。docstring に更新頻度と「基準日」を明記してください。

  • ページネーションを公開する。 utils.py の PaginationParams / paginate() を使用し、has_more / next_offset を返します。

  • 明示的なタイムアウトを使用する。 utils.fetch_json はデフォルトで30秒です。

  • 実用的なエラーを返す。 生のスタックトレースではなく、hint を含むエラー dict を返します。


デプロイ

ローカル開発では stdio を使用します。サーバーをエージェントプラットフォームと共有するには、デプロイして登録します。選択肢については deploy/README.md を参照してください:

  • IBM watsonx Orchestrate — deploy/ibm/(ローカル stdio ツールキット、Code Engine の Git からのビルド、ビルド済みイメージの3つのキット)。

  • Databricks Apps — deploy/databricks/。

どちらも同じサーバーコードを読み取ります。app.py は、プラットフォームがポートを注入すると自動的に HTTP を提供します。


評価

LLM がツールをどれだけうまく使えるかを測定することは、サーバー品質の真のテストです。このテンプレートには意図的に評価ハーネスは含まれていません。mcp-eval スキルを使用して評価ハーネスを構築する方法については eval/README.md を参照してください。


ライセンス

MIT。脆弱性開示ポリシーとハッカソンのセキュリティメモについては SECURITY.md を参照してください。

Available Tools

1 tool
example_search_datasetsSearch Datasets (example)B
Read-onlyIdempotent

Search federal datasets matching a query string. (STUB — replace me.)

This stub shows the shape of a real tool without calling a live API. Swap the body for an actual request using fetch_json(...); a worked pattern is included below in a comment.

Inputs: query (required), pagination, response_format. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 1 tool

    Disambiguation5/5

    Only one tool exists, so there is no possibility of confusion or overlap. The sole tool has a clear, singular purpose.

    Naming Consistency5/5

    With a single tool, there is no inconsistency in naming conventions. The name follows a verb_noun pattern (search_datasets).

    Tool Count1/5

    A single stub tool is a trivial surface for a server, far below the typical 3-15 tool range. It does not constitute a meaningful tool set.

    Completeness1/5

    The server is explicitly a stub with no real functionality, offering only a placeholder search. It has no coverage of any actual domain or workflow.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A basic MCP server template that provides a foundation for building custom tools, resources, and prompts. Serves as a starting point for developers to create their own MCP server functionality.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A foundational template for building MCP servers in Python using Streamable HTTP transport. Provides example implementations of tools, resources, and prompts to help developers create custom MCP integrations for AI assistants.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A minimal template MCP server demonstrating basic tools, resources, and prompts functionality. Includes example implementations like a hello tool, history resource, and greet prompt for learning MCP development.
      ISC