toke mcp
](https://www.npmjs.com/package/@tokelang/mcp-server) 
将您的AI编码助手连接到 托克 编程语言。此MCP服务器为Claude、Cursor和VS Code等工具提供了编写、编译和理解代码的能力。它实现了 模型上下文协议 有14个工具,SSE传输、速率限制和IDE集成。
特性
- 14个MCP工具 用于编译、检查、格式化、生成和分析toke代码
- SSE运输 具有会话管理和健康检查功能
- 速率限制 具有内存或Redis支持的存储
- IDE集成 适用于Claude Code、VS Code和Codex CLI
- 可嵌入的 --出口
createMcpServer()和createApp()用于自定义基础架构 - 自助式 使用Docker或独立的Node.js
快速开始
# Requires: Node.js >= 18, tkc compiler on PATH
npm install @tokelang/mcp-server
npx toke-mcp或者使用Docker:
docker compose up服务器启动于 http://localhost:3000 与:
GET /mcp/sse--SSE连接端点POST /mcp/messages?sessionId=...--JSON-RPC消息端点GET /health--健康检查
可用工具
| 工具 | 说明 |
|---|---|
toke_check | 检查源代码是否有错误,返回JSON诊断 |
toke_compile | 将toke源代码编译为LLVM IR |
toke_explain_error | 查找带有修复建议的错误代码 |
toke_spec_lookup | 按关键字搜索语言规范 |
toke_stdlib_ref | 查找标准库模块或函数文档 |
toke_generate | 从自然语言描述生成toke代码 |
toke_bench | 将代码与已知任务进行基准测试 |
toke_companion | 生成、验证或区分 .tkc.md 配套文件 |
toke_format | 自动格式化源代码 |
toke_migrate | 将传统的80字符语法迁移为56字符默认语法 |
toke_compress | 使用toke压缩来压缩文本 |
toke_decompress | 解压缩压缩文本 |
toke_analyse | 不修改输入的飞行前代币预算估算 |
toke_render | 使用渲染参数化模板 {{varname}} 替代品 |
有关详细的输入/输出模式,请参阅 TOOLS.md.
IDE集成
克劳德桌面版
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"toke": {
"command": "npx",
"args": ["toke-mcp"]
}
}
}克劳德代码
将插件复制到您的项目中:
cp -r claude-plugin/.mcp.json .mcp.json
cp -r claude-plugin/CLAUDE.md CLAUDE.md
cp -r claude-plugin/skills/ skills/
cp -r claude-plugin/commands/ commands/看 claude-plugin/README.md 了解全部细节。
VS Code
从源代码安装扩展:
cd vscode-toke
npm install && npm run compile
npx vsce package
code --install-extension toke-language-0.1.0.vsix看 vscode-toke/README.md 用于配置和代码片段。
光标
添加到光标MCP设置(设置>MCP服务器):
{
"toke": {
"command": "npx",
"args": ["toke-mcp"]
}
}Codex CLI
复制 codex/codex.md 和 codex/mcp.json 进入你的项目根目录。看 codex/README.md.
配置
| 环境变量 | 默认值 | 描述 |
|---|---|---|
PORT | 3000 | 服务器端口 |
TKC_PATH | tkc | tkc编译器二进制文件的路径 |
RATE_LIMIT_PER_HOUR | 100 | 每个IP每小时的最大请求数 |
MAX_CONNECTIONS | 5 | 每个IP的最大并发SSE连接数 |
REDIS_URL | -- | 用于速率限制的Redis URL(可选,内存回退) |
延伸
服务器导出 createMcpServer() 和 createApp() 用于嵌入您自己的基础设施:
import { createApp, createMcpServer } from "@tokelang/mcp-server";
const app = createApp({
onConnect: async (req) => {
return { allowed: true };
},
onToolCall: async (req, toolName, clientIp) => {
return { allowed: true, headers: {} };
},
onToolComplete: (toolName, clientIp, latencyMs, success) => {
// Usage tracking, telemetry, etc.
},
});
app.listen(3000);项目结构
toke-mcp/
server.js MCP server with all 14 tools registered
tools/ Individual tool implementations
lib/ Rate limiting, connection registry, caching
bin/ CLI entry point (npx toke-mcp)
skills/ Language skill definition
claude-plugin/ Claude Code plugin (MCP config, skills, commands)
codex/ Codex CLI integration
vscode-toke/ VS Code extension (syntax, snippets, LSP client)
lsp/ Language server (diagnostics, hover, symbols)
lambda/ AWS Lambda handlers
test/ Tests and compatibility suite
scripts/ Build and publish scripts自我寄宿
看 自我封闭.md 用于Docker部署和生产配置。
贡献
看 贡献.md 关于开发设置、代码风格以及如何添加新工具。
