Crimson Crab Mcp Template

io.github.singhpratech由 GitHub 账号 singhpratech 发布v0.3.1更新于 Oct 24, 2026

Ready-to-clone Rust MCP server with chat, token-counting, and model tools for Claude

已验证STDIO仅桌面开发者工具AI 与机器学习

概览

AI 生成的概览

一个 Rust 起步模板,向 MCP 客户端(如 Claude Desktop)提供 Claude 对话、token 计数和模型查询工具。

可以做什么
它提供五个工具:ask_claude 发送提示并返回 Claude 的回复,chat 发送完整多轮对话历史并返回下一轮回复,count_tokens 在不实际调用的情况下估算提示的输入 token 数,list_models 列出当前 API 密钥可用的模型,get_model 返回某个模型的上下文窗口和输出上限。它是一个精简的参考实现,用于克隆或生成后作为构建自有 Claude 相关 MCP 工具的起点。
适用场景
如果你想找一个可运行的小型 Rust MCP 服务器示例来调用 Claude,或希望在 MCP 客户端中使用 Claude 对话与 token 估算工具,可以考虑它。它是模板而非成品,实际使用前通常需要自行修改。
运行要求
需要本地 Rust 工具链来构建和运行,并通过 ANTHROPIC_API_KEY 环境变量提供 Anthropic API 密钥。它以本地 stdio 进程方式运行,必须由 MCP 客户端启动;README 给出了写入 Claude Desktop 配置文件的示例。访问 Claude API 需要网络连接。
安装前请注意
它需要 Anthropic API 密钥(ANTHROPIC_API_KEY),该密钥通过客户端的环境配置传入进程,应避免写入共享配置文件。工具调用会把提示和对话历史发送到 Anthropic 的 API,并消耗付费额度;可先用 count_tokens 估算成本。它是起步模板,依赖前请先审阅并调整代码。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Crimson Crab Mcp Template,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Claude-powered MCP server in Rust (starter template)

[crimson-crab-mcp-template MCP server] [crates.io] [license]

A minimal, production-ready Model Context Protocol (MCP) server, written in Rust, backed by Anthropic's Claude API through the crimson-crab SDK. It exposes five tools: ask_claude (send a prompt, get Claude's reply), chat (multi-turn conversation), count_tokens (price a prompt without running it), list_models (enumerate the models your API key can use), and get_model (limits and metadata for one model).

Use it as the reference starting point for building your own Claude-powered MCP tools in Rust.

Use this template

Click Use this template on GitHub, or generate a fresh project with cargo generate:

sh
cargo generate --git https://github.com/singhpratech/crimson-crab-mcp-template

You can also just clone it:

sh
git clone https://github.com/singhpratech/crimson-crab-mcp-template

Quickstart

sh
export ANTHROPIC_API_KEY=sk-ant-...cargo run

The server communicates over stdio, so running it directly just waits for an MCP client to connect. All logging goes to stderr — stdout is reserved for the MCP protocol. Set RUST_LOG=debug for more verbose logs.

To build an optimized binary you can point a client at:

sh
cargo build --release# -> target/release/crimson-crab-mcp-template

Wire it into Claude Desktop

Add an entry to your Claude Desktop MCP config (claude_desktop_config.json), pointing at the built binary and passing your API key through the environment:

json
{  "mcpServers": {    "claude-via-crimson-crab": {      "command": "/absolute/path/to/target/release/crimson-crab-mcp-template",      "env": {        "ANTHROPIC_API_KEY": "sk-ant-..."      }    }  }}

Restart Claude Desktop; the ask_claude, chat, count_tokens, list_models, and get_model tools will then be available.

The tools

ask_claude

ParameterTypeRequiredDescription
promptstringyesThe prompt to send to Claude.
systemstringnoOptional system prompt.

Builds a Claude Messages request (defaulting to the claude-opus-5 model), calls the API, and returns the concatenated text of Claude's reply.

chat

ParameterTypeRequiredDescription
messagesarrayyesThe conversation so far, oldest first: {role, content} where role is an enum constrained to "user" or "assistant". Must end with a user turn.
systemstringnoOptional system prompt.
modelstringnoModel id (defaults to the ask_claude model).
max_tokensintegernoMaximum tokens to generate (default 1024).

Sends the whole message history to Claude and returns the next reply — use it instead of ask_claude when the caller needs to keep context across turns.

count_tokens

ParameterTypeRequiredDescription
promptstringyesThe prompt whose token count you want.
systemstringnoOptional system prompt to include in the count.
modelstringnoModel id to count against (counts are model-specific).

Returns the number of input tokens the prompt would consume, without running it — useful for estimating cost before an expensive call.

list_models

ParameterTypeRequiredDescription
limitintegernoMaximum number of models to return.

Returns the id, display name, and release date of each Claude model available to the configured API key.

get_model

ParameterTypeRequiredDescription
modelstringyesThe model id to look up, e.g. claude-opus-5.

Returns the model's display name, release date, context window (max_input_tokens), and maximum output tokens.

Errors from all tools are returned as MCP tool errors rather than panicking. The Claude client is built once at startup and reused across calls.

Built with crimson-crab

This template is built with crimson-crab — a production-grade Rust SDK for Anthropic's Claude API. Source: https://github.com/singhpratech/crimson-crab.

License

Licensed under either of

at your option.


crimson-crab is an independent open-source project and is not affiliated with Anthropic.

来源:README.md,提交 d0a492f

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分