Skip to main content
Glama

Go MCP Go SDK Gin 测试 许可证 二进制大小


📋 目录


Related MCP server: Relay

🦕 是什么——以及为什么

dino-mcp 是一个用 Go 编写的 模型上下文协议 (MCP) 参考实现,展示了现代 MCP 栈的每一层:

实现

为什么重要

传输层

stdio + Streamable HTTP

既可在 Claude Desktop 中使用,也可在 Web 浏览器中使用

MCP 应用

@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 工具

基于 stdio 的 JSON-RPC

Claude Desktop

文本工具 (dino_think, dino_ask)

MCP 应用

基于 stdio + postMessage 的 JSON-RPC

Claude Desktop iframe

交互式 UI (dino_dashboard)

独立模式

HTTP GET

浏览器

直接访问 (/dashboard, /api/dinosaurs)


✨ 特性

特性

状态

备注

工具 (tools/list, tools/call)

✅ 完成

3 个类型化工具,返回结构化 JSON 响应

资源 (resources/list, resources/read)

✅ 完成

//go:embed HTML 以 ui:// URI 形式提供

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.com URL

  • 无需 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 应用 → 渲染 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 应用

{"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 编码代理

📚 深入架构

ARCHITECTURE.md

高级工程师

📐 技术规格

TECH_DESIGN.md

实现团队

⏳ 开发历史

MEMORY.md

所有贡献者

📋 路线图

PLAN.md

利益相关者

⚖️ 设计权衡

DESIGN.md

架构师

🎯 技能参考

SKILL.md

开发者 / AI 代理

🤝 如何贡献

CONTRIBUTOR.md

贡献者

📜 行为准则

CODE_CONDUCT.md

社区

📄 ADRs

docs/adr/

决策记录者

🤖 LLM 完整上下文

llms-full.txt

AI 代理 (RAG)


📊 项目状态

MVP ── Production ── Enhanced UI ── Ecosystem ── Advanced
  ●                    ○               ○             ○

阶段

状态

亮点

MVP

✅ 完成

3 个工具,MCP Apps UI,7 个测试,文档

生产化

🔄 进行中

Go 单元测试,CI,速率限制,Docker

增强 UI

📅 已计划

实时数据,比较,时间线

生态系统

📅 已计划

Homebrew,GitHub 发布,MCP 注册表

高级功能

💭 未来

流式工具输入,WebSocket 同步

构建指标

指标

二进制大小

~11 MB (压缩后)

二进制类型

Mach-O 64-bit arm64

Go 版本

1.25

MCP SDK 版本

v1.7.0

依赖

30+ 个 Go 模块 (均为间接依赖)

UI 包

354 KB 内嵌 HTML (单文件 Vite)

测试覆盖率

7/7 集成测试通过 (基于 shell;尚无 Go 单元测试)


📖 延伸阅读


F
license - not found
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)

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
    -
    quality
    D
    maintenance
    A production-ready MCP server with tools for weather, calculator, and mock database queries, plus resources and prompt templates, featuring a glassmorphism admin dashboard and WebSocket support.
  • A
    license
    -
    quality
    A
    maintenance
    A single MCP server with 40 tools across 7 categories - PM, Research, Brand, UX, GTM, File, and Web. Built in Go, zero dependencies, one binary. Handles file operations, web fetching, screenshots, search, and planning workflows through one MCP connection.
    11
    MIT
  • F
    license
    -
    quality
    C
    maintenance
    A self-hosted MCP gateway that aggregates all your MCP servers behind a single Streamable HTTP endpoint, with automatic registry discovery (19,000+ servers), on-demand Docker provisioning, multi-device support via SSH, OAuth2 PKCE authentication, and a workflow engine for saving and replaying multi-step tool sequences.

View all related MCP servers

Related MCP Connectors

  • A MCP server built for developers enabling Git based project management with project and personal…

  • MCP server for InsForge BaaS — database, storage, edge functions, and deployments

  • Go MCP server for GitLab: 2 dynamic tools reach 1000+ REST/GraphQL actions. Free/CE, no paid tier.

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/shennawardana23/mcp-dino'

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