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 分