MCP Hackathon Server
OfficialGSA MCP 黑客马拉松 — 服务器模板
一个即用型入门项目,用于在 Python 中构建 Model Context Protocol (MCP) 服务器,并附带 IBM Cloud (watsonx Orchestrate) 和 Databricks 的部署套件。
基于 FastMCP 和 uv 构建。如果你从未构建过 MCP 服务器,请从 QUICKSTART.md 开始。
什么是 MCP 服务器?
MCP 服务器向 AI 客户端(如 Claude Desktop、Claude Code 或 watsonx Orchestrate 等代理平台)暴露 工具(模型可调用的函数)、提示词(可复用的对话开场白)和 资源(模型可读取的数据)。你编写工具;客户端的模型决定何时调用它们。
本模板为你提供了一个包含各类示例各一个的可运行服务器,因此你可以用自有服务替换这些示例并进行部署。
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一工具一文件的模式
每个工具都位于 src/example_server/tools/ 下的独立文件中,并暴露一个 register(mcp) 函数。tools/__init__.py 通过单个 register_tools(mcp) 调用每个工具。这样可以让工具列表一目了然,并且只需改动两个文件即可添加或移除一个集成。
第 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 步 — 在 config.py 中添加任何 API 密钥作为类型化字段,并在 .env.example 中记录该环境变量。
提示词(prompts/)和资源(resources/)遵循完全相同的 register(mcp) + 聚合器模式。
重命名包
在发布服务器之前,将 example_server 重命名为你的服务名(例如 census_mcp):
将文件夹
src/example_server/重命名为src/<your_name>/。更新
pyproject.toml:[project].name、[project].scripts和[tool.hatch.build.targets.wheel].packages。在
src/、tests/、main.py、Dockerfile和manifest.yaml中查找并替换example_server。
工具设计建议(面向联邦数据)
返回结构化数据,而非散文。 返回键一致的字典/列表,让模型自行叙述。
注明数据新鲜度。 联邦数据集存在滞后;在 docstring 中说明更新频率和“截至”日期。
暴露分页。 使用
utils.py中的PaginationParams/paginate(),并返回has_more/next_offset。使用显式超时。
utils.fetch_json默认超时为 30 秒。可操作性的错误。 返回带有
hint的错误字典,而不是原始堆栈跟踪。
部署
本地开发使用 stdio。要将服务器共享给代理平台,请部署并注册它。参见 deploy/README.md 以选择方案,然后:
IBM watsonx Orchestrate — deploy/ibm/(三套方案:本地 stdio 工具包、Code Engine 从 Git 构建、以及预构建镜像)。
Databricks Apps — deploy/databricks/。
两者读取相同的服务器代码;当平台注入端口时,app.py 会自动提供 HTTP 服务。
评估
衡量 LLM 使用你的工具的能力,才是对服务器质量的真正考验。本模板有意不附带评估工具 — 参见 eval/README.md 以了解如何使用 mcp-eval 技能构建评估工具。
许可证
MIT。参见 SECURITY.md 了解漏洞披露政策和黑客马拉松安全注意事项。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA 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.
- FlicenseNot gradedqualityDmaintenanceA 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.
- AlicenseNot gradedqualityDmaintenanceA 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.1ISC
- FlicenseNot gradedqualityDmaintenanceEducational example of an MCP server built with FastMCP, demonstrating how to expose tools, resources, and prompts for AI clients.
Related MCP Connectors
MCP server for generating rough-draft project plans from natural-language prompts.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server exposing the Backtest360 engine API as tools for AI agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/GSA-TTS/mcp-hackathon-template'
If you have feedback or need assistance with the MCP directory API, please join our Discord server