关于 mcp-dino
mcp-dino 是用 Go 编写的 MCP 参考实现,通过恐龙数据和交互式仪表板演示 MCP 工具、资源及 MCP Apps。适合学习 MCP 实现或构建 Go 服务的开发者,也可在浏览器独立查看仪表板。
主要功能
- 01提供三种恐龙相关工具
- 02在 MCP App 中显示交互仪表板
- 03支持 stdio 与 Streamable HTTP
- 04以内嵌 HTML 提供资源
- 05无需 API 密钥即可运行
适用场景
- 01学习 Go 中的 MCP 服务实现
- 02测试 MCP Apps 交互界面
- 03在客户端或浏览器查看恐龙数据
MCP 相关
这是 MCP 服务,支持 stdio 和 Streamable HTTP,提供三个工具、HTML 资源及基于 MCP Apps 的仪表板。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
生产级 MCP 服务,配备交互式 HTML 仪表盘 UI — 以 Go 编写,精心设计,令人愉悦。
📋 目录
🦕 是什么 — 为什么
dino-mcp 是一个使用 Go 实现的 Model Context Protocol(MCP) 参考实现,展示了现代 MCP 技术栈的每一层:
| 层 | 实现方式 | 重要性 |
|---|---|---|
| 传输 | stdio + Streamable HTTP | 兼容 Claude Desktop 和 Web 浏览器 |
| MCP Apps | @modelcontextprotocol/ext-apps App 类 | 在 Claude Desktop iframe 中呈现交互式 HTML UI |
| 工具 | dino_think、dino_ask、dino_dashboard | 类型化的 Go 处理程序、结构化 JSON 结果 |
| 资源 | //go:embed HTML → text/html;profile=mcp-app | 独立的 ~11MB 二进制文件,运行时零依赖 |
无论你是要从头构建 MCP 服务、学习 MCP Apps 协议,还是需要 Go — Gin — ext-apps SDK 集成蓝图,本项目都能满足你的需求。
⚡ 快速开始
# Clone & enter
git clone https://github.com/shennawardana23/mcp-dino.git && cd mcp-dino
# Build & run in one shot (≈2 seconds)
make build-fast && make dev-http
# Open the standalone dashboard
open http://localhost:9010/dashboard
预期输出 — 点击展开
=== dino-mcp server ===
Transport: http
Listening on :9010
[GIN] 2026/06/21 - 12:30:00 | 200 | 4.2ms | ::1 | GET "/dashboard"
[GIN] 2026/06/21 - 12:30:01 | 200 | 2.1ms | ::1 | GET "/api/dinosaurs"
🏗 架构概览
flowchart TB
subgraph CLI["CLI Layer"]
STDIO["stdio subcommand"]
HTTP["http subcommand"]
end
subgraph SERVER["Server (internal/server/)"]
GIN["Gin Router :9010"]
MCPH["MCP StreamableHTTPHandler"]
CORS["CORS Middleware"]
TOOLS["Tools: think · ask · dashboard"]
RES["Resources: //go:embed HTML"]
end
subgraph UI["View (ui/src/)"]
APP["ext-apps App class"]
POST["postMessage protocol"]
end
subgraph FALLBACK["Standalone Fallback"]
DASH["/dashboard (HTML)"]
API["/api/dinosaurs (JSON)"]
end
CLI --> GIN
GIN --> CORS
CORS --> MCPH
MCPH --> TOOLS
TOOLS --> RES
RES --> APP
APP --> POST
MCPH -.->|"MCP Apps"| APP
GIN -.->|"direct route"| DASH
GIN -.->|"direct route"| API
style CLI fill:#1a1a2e,color:#e0e0e0,stroke:#2d2a44
style SERVER fill:#1a1a2e,color:#e0e0e0,stroke:#2d2a44
style UI fill:#1a1a2e,color:#e0e0e0,stroke:#2d2a44
style FALLBACK fill:#1a1a2e,color:#e0e0e0,stroke:#2d2a44
style STDIO fill:#2d2a44,color:#a78bfa
style HTTP fill:#2d2a44,color:#a78bfa
style GIN fill:#0099e5,color:#fff
style MCPH fill:#a78bfa,color:#fff
style TOOLS fill:#22c55e,color:#fff
style RES fill:#22c55e,color:#fff
style APP fill:#facc15,color:#000
style POST fill:#facc15,color:#000
style DASH fill:#f87171,color:#fff
style API fill:#f87171,color:#fff
数据通过三条管道流动:
| 管道 | 协议 | 客户端 | 用途 |
|---|---|---|---|
| MCP Tools | JSON-RPC over stdio | Claude Desktop | 文本工具(dino_think、dino_ask) |
| MCP Apps | JSON-RPC over stdio + postMessage | Claude Desktop iframe | 交互式 UI(dino_dashboard) |
| 独立模式 | HTTP GET | 浏览器 | 直接访问(/dashboard、/api/dinosaurs) |
✨ 功能
符合 MCP 标准
| 功能 | 状态 | 说明 |
|---|---|---|
工具(tools/list、tools/call) | ✅ 完成 | 3 个类型化工具,提供结构化 JSON 响应 |
资源(resources/list、resources/read) | ✅ 完成 | 通过 ui:// URI 提供 //go:embed HTML |
| MCP Apps 协议 | ✅ 完成 | _meta.ui.resourceUri + ui/initialize 握手 |
| stdio 传输 | ✅ | Claude Desktop、Cursor、Copilot |
| Streamable HTTP | ✅ | MCP Inspector、curl、浏览器、隧道 |
| SSE 传输 | ❌ 已移除 | 已在 MCP 规范 v2025-11-25 中弃用 |
开发者体验
- 3 秒构建周期 —
make build-fast && make dev-http - 7 项集成测试 —
make test会测试每个协议方法 - 交互式调试 —
make test-inspector会启动 MCP Inspector - 远程测试 —
make run-tunnel会创建一个公开的trycloudflare.comURL - 无需 API 密钥 — 所有恐龙数据都内置于二进制文件中
- 运行时依赖为零 — 单个静态二进制文件,内嵌 HTML
交互式仪表盘
dino_dashboard 工具会在 Claude Desktop 的 iframe 中渲染 HTML 卡片网格:
- 按食性筛选 — 食肉、食草,或显示全部
- 按时期筛选 — 三叠纪、侏罗纪、白垩纪
- 12 种恐龙 — 从霸王龙到迅猛龙
- 备用模式 — 直接在
http://localhost:9010/dashboard打开
注意:筛选器会在调用工具时于服务端应用。使用特定筛选条件打开后,应用内的筛选按钮只能在同一结果集中进一步缩小范围,无法扩大范围以显示初始调用排除的物种。
HTML 视图使用官方 @modelcontextprotocol/ext-apps SDK 构建,并通过 postMessage 使用 JSON-RPC 进行通信。
🎮 试用
在 Claude Desktop 中
Show me the dinosaur dashboard with carnivores
→ Claude 检测到 MCP App → 渲染 iframe → 你会看到可筛选的恐龙卡片
在浏览器中
open http://localhost:9010/dashboard
→ 独立 HTML 页面,所有恐龙数据均从内置 REST API 获取
使用 MCP Inspector
make test-inspector
→ 打开 http://localhost:5173 → 连接到 http://localhost:9010/mcp
通过 curl
# Initialize
curl -s -X POST http://localhost:9010/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}' \
| python3 -m json.tool
# List tools
SID="<session-id-from-above>"
curl -s -X POST http://localhost:9010/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Session-Id: $SID" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
| python3 -m json.tool
# Call dino_think
curl -s -X POST http://localhost:9010/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Session-Id: $SID" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"dino_think","arguments":{}}}' \
| python3 -m json.tool
🔧 工具参考
| 工具 | 类型 | 输入 | 输出 | 提示词示例 |
|---|---|---|---|---|
dino_think | 文本 | {} | 随机知识 + 物种 JSON | “告诉我一个关于恐龙的知识” |
dino_ask | 文本 | {"question": "..."} | 答案 + 问题 JSON | “霸王龙吃什么?” |
dino_dashboard | MCP App | {"filter": "Carnivore"} | HTML iframe + JSON 数据 | “给我看看食肉恐龙” |
无论提问内容是什么,
dino_ask目前都会返回相同的恐龙时代概述——它尚未根据问题文本进行分支处理。此项已记录为已知限制。
dino_think 响应示例:
{
"content": [
{ "type": "text", "text": "🦕 Did you know? The Velociraptor was only about the size of a turkey!" }
],
"structuredContent": {
"fact": "The Velociraptor was only about the size of a turkey",
"species": "Velociraptor"
}
}
dino_dashboard 响应示例:
{
"content": [
{ "type": "text", "text": "Displaying dinosaur dashboard with 4 dinosaurs (filter: Carnivore)" }
],
"structuredContent": {
"filter": "Carnivore",
"dinosaurs": [
{
"name": "Tyrannosaurus Rex",
"period": "Cretaceous",
"diet": "Carnivore",
"length": "40 ft (12 m)",
"weight": "9 tons (8,000 kg)",
"funFact": "T-Rex had the strongest bite of any land animal ever",
"imageStyle": "bg-red-900"
}
],
"timestamp": "2026-06-21T12:00:00Z"
}
}
💬 Claude Desktop 集成
CLI 模式(stdin/stdout)
找到二进制文件,并将其添加到 claude_desktop_config.json:
{
"mcpServers": {
"dino-mcp": {
"command": "/absolute/path/to/mcp-dino/bin/dino-mcp",
"args": ["stdio"]
}
}
}
保存后,重启 Claude Desktop。聊天时,工具旁会显示锤子图标(🔨)——点击即可直接调用,也可以让 Claude 自行决定。
HTTP 模式(用于调试)
make dev-http
# Server starts on :9010
🛠 开发
前置条件
| 工具 | 版本 | 用途 |
|---|---|---|
| Go | ≥ 1.25 | 服务二进制文件 |
| Node.js | ≥ 18 | UI 构建(Vite) |
| cloudflared | 任意 | 用于远程测试的隧道 |
命令
# Build — three options
make build # Full: Vite UI + Go binary
make build-fast # Quick: Go binary only (reuses existing UI)
make build-ui # Vite UI only
# Run
make dev-http # HTTP mode with verbose logging
make run-stdio # stdio mode for Claude Desktop
make run-tunnel # HTTP + Cloudflare Tunnel
# Test & verify
make test # 7 integration tests — all must pass
make test-inspector # Launch MCP Inspector in browser
make lint # go vet + go fmt
# Utility
make help # All targets with descriptions
make clean # Remove all build artifacts
项目结构
mcp-dino/
├── bin/ # Go build output (~11MB static binary)
├── cmd/dino-mcp/main.go # CLI entry point (stdio | http | help)
├── internal/
│ ├── server/
│ │ └── server.go # Composition root: mcp.Server + Gin + CORS
│ ├── tools/
│ │ ├── tools.go # Shared types, constants, helpers
│ │ ├── think.go # RegisterThink (dino_think tool)
│ │ ├── ask.go # RegisterAsk (dino_ask tool)
│ │ └── dashboard.go # RegisterDashboardTool + 12 dino species + REST API
│ └── resources/
│ ├── dashboard.go # RegisterDashboardResource + //go:embed HTML
│ └── dashboard_ui.html # Vite-built HTML (354KB)
├── ui/
│ └── src/
│ └── mcp-app.ts # ext-apps App class + postMessage
├── docs/ # Diátaxis documentation (see below)
├── test_mcp.sh # 7 integration tests
├── AGENTS.md # AI agent instructions (canonical)
├── ARCHITECTURE.md # C4 diagrams + sequence flows
├── TECH_DESIGN.md # Interface contracts + data model
├── Makefile # All targets
├── go.mod + go.sum # Go dependencies
└── README.md # ← you are here
🗺 文档导航
dino-mcp 使用 Diátaxis 框架——四种文档模式,分别满足不同需求。
| 面向的读者 | 从这里开始 | 读者 |
|---|---|---|
| 👋 项目新手 | 快速开始 | 所有人 |
| 🧑💻 添加工具 | 你的第一个工具 | 开发者 |
| 🦕 添加恐龙 | 添加恐龙 | 内容编辑者 |
| 🧪 使用 Inspector 测试 | 使用 Inspector 测试 | QA / 开发者 |
| 🔍 查阅参考资料 | CLI 参考 | 运维人员 |
| 🏗 了解设计 | 架构 | 架构师 |
| 🤖 通过 AI 实现 | AGENTS.md | AI 编码 Agent |
| 📚 深入了解架构 | ARCHITECTURE.md | 资深工程师 |
| 📐 技术规范 | TECH_DESIGN.md | 实施团队 |
| ⏳ 开发历史 | MEMORY.md | 所有贡献者 |
| 📋 路线图 | PLAN.md | 利益相关者 |
| ⚖️ 设计权衡 | DESIGN.md | 架构师 |
| 🎯 Skills 参考 | SKILL.md | 开发者 / AI Agent |
| 🤝 如何贡献 | CONTRIBUTOR.md | 贡献者 |
| 📜 行为准则 | CODE_CONDUCT.md | 社区 |
| 📄 ADR | docs/adr/ | 决策记录者 |
| 🤖 LLM 完整上下文 | llms-full.txt | AI Agent(RAG) |
📊 项目状态
MVP ── Production ── Enhanced UI ── Ecosystem ── Advanced
● ○ ○ ○
| 阶段 | 状态 | 亮点 |
|---|---|---|
| MVP | ✅ 已完成 | 3 个工具、MCP Apps UI、7 项测试、文档 |
| 生产就绪 | 🔄 进行中 | Go 单元测试、CI、速率限制、Docker |
| 增强型 UI | 📅 计划中 | 实时数据、比较、时间线 |
| 生态系统 | 📅 计划中 | Homebrew、GitHub 发布、MCP Registry |
| 高级功能 | 💭 未来 | 流式工具输入、WebSocket 同步 |
构建指标
| 指标 | 值 |
|---|---|
| 二进制文件大小 | ~11 MB(压缩后) |
| 二进制文件类型 | Mach-O 64 位 arm64 |
| Go 版本 | 1.25 |
| MCP SDK 版本 | v1.7.0 |
| 依赖项 | 30+ 个 Go 模块(均为间接依赖) |
| UI 包 | 354 KB 嵌入式 HTML(单文件 Vite) |
| 测试覆盖率 | 7/7 项集成测试通过(基于 shell;尚无 Go 单元测试) |
📖 延伸阅读
| 资源 | 链接 |
|---|---|
| MCP 规范 | spec.modelcontextprotocol.io |
| MCP Go SDK | github.com/modelcontextprotocol/go-sdk |
| MCP Apps 协议 | modelcontextprotocol.io/docs/apps/overview |
| ext-apps SDK | github.com/modelcontextprotocol/ext-apps |
| Gin Web 框架 | github.com/gin-gonic/gin |
| Go 编程语言 | go.dev |
使用 Go、 Gin、 MCP Go SDK 和 @modelcontextprotocol/ext-apps 倾情打造
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。