IS

iceener/streamable-mcp-server-template

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

145 stars 55 forks 质量 76 趋势 30MIT

iceener/streamable-mcp-server-template 是从 https://github.com/iceener/streamable-mcp-server-template. 导入的 MCP 服务器候选

概览

iceener/streamable-mcp-server-template 是从 https://github.com/iceener/streamable-mcp-server-template. 导入的 MCP 服务器候选

概述(AI 翻译)

该模板是一个远程模型上下文协议(MCP)服务器。它运行于 Bun 和 Cloudflare Workers 上。它使用官方的 MCP TypeScript SDK。

服务器使用协议版本 2026-07-28。它也接受使用 2025 协议版本的客户端。

该模板包含以下功能:

  • 检查Host和Origin头部。
  • OAuth 令牌检查。服务器是 OAuth 资源服务器。你的代码不会接收令牌。
  • 错误策略。服务器不会向客户端发送内部错误数据。
  • 在 Bun 和 Cloudflare Workers 上运行的测试。

样本服务器提供Open-Meteo的天气数据。Open-Meteo不需要API密钥。用你的工具替换样本。保留模板的其他部分。

要求

  • Bun 1.4或更高版本。
  • Node.js 22.18 或更晚。Wrangler 指令和烟雾测试使用Node.js。

启动服务器

  1. 安装依赖:

  2. 启动服务器:

服务器网址为 http://127.0.0.1:3000/mcp。

要使用 Cloudflare 本地运行时,运行 bun run dev:worker。服务器 URL 是 http://127.0.0.1:8787/mcp。

连接客户

使用服务器URL和可流式HTTP传输。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Server Template

This template is a remote Model Context Protocol (MCP) server. It runs on Bun and on Cloudflare Workers. It uses the official MCP TypeScript SDK.

The server uses protocol version 2026-07-28. It also accepts clients that use the 2025 protocol versions.

The template includes these functions:

  • Checks of the Host and Origin headers.
  • OAuth token checks. The server is an OAuth resource server. Your code does not receive the token.
  • An error policy. The server does not send internal error data to clients.
  • Tests that run on Bun and on Cloudflare Workers.

The sample server gives weather data from Open-Meteo. Open-Meteo does not require an API key. Replace the samples with your tools. Keep the other parts of the template.

Requirements

  • Bun 1.4 or later.
  • Node.js 22.18 or later. The Wrangler commands and the smoke tests use Node.js.

Start the server

  1. Install the dependencies:

    bun install
    
  2. Start the server:

    bun run dev
    

The server URL is http://127.0.0.1:3000/mcp.

To use the Cloudflare local runtime, run bun run dev:worker. The server URL is then http://127.0.0.1:8787/mcp.

Connect a client

Use the server URL and the Streamable HTTP transport.

Client Procedure
MCP Inspector Run bun run inspector. Select Streamable HTTP. Enter the server URL.
Claude Code Run claude mcp add --transport http weather http://127.0.0.1:3000/mcp.
VS Code Add { "servers": { "weather": { "type": "http", "url": "http://127.0.0.1:3000/mcp" } } } to .vscode/mcp.json.
Cursor Add { "mcpServers": { "weather": { "url": "http://127.0.0.1:3000/mcp" } } } to ~/.cursor/mcp.json.

To test the connection, send a request. For example: “What is the weather in Kraków this week?”

Samples

Each sample shows one procedure.

Sample Type Shows
get-forecast Tool A call to an external API through a service. It shows cancellation, progress, and errors that the model can correct.
echo Tool The smallest complete tool: an input schema, an output schema, and annotations.
whoami Tool How to read the identity of the verified caller.
confirm-action Tool How to ask the user for approval during a call (input_required). The tool also requires an OAuth scope.
docs://server/guide Resource A static resource.
weather://codes/{code} Resource template How to list, read, and complete URIs from a template.
weather-briefing Prompt Prompt arguments and argument completion.

Project structure

src/
  server.ts       Server identity, dependencies, token verification, extra routes, McpServer factory
  settings.ts     Settings for your code, for example API keys
  tools/          ┐
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →