Token导航 LogoToken导航TokenDH.com
Spin Trigger MCP logo
AI代理未说明官方级别未说明来源级核验

Spin Trigger MCP

MCP Server

一个Spin触发器插件,使WebAssembly组件能够作为模型上下文协议(MCP)服务器运行,支持完整的MCP协议和JSON-RPC 2.0传输。

工具数

1

提示词数

0

GitHub Stars

0

资源数

0
RustClaudeAI工具集成Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

fastertools

提供方

fastertools

最后核验

2026/5/17 20:23

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

自旋MCP触发器插件

一个Spin触发器插件,使WebAssembly组件能够充当模型上下文协议(MCP)服务器。

特性

  • 完全支持MCP协议(工具、资源、提示)
  • 基于HTTP传输的JSON-RPC 2.0
  • 将MCP服务器轻松部署为Spin应用程序
  • 与Claude Desktop和其他MCP客户端兼容

快速开始

1.安装插件和模板

来源:

git clone https://github.com/fastertools/spin-trigger-mcp.git
cd spin-trigger-mcp
make

这将:

  • 构建并安装 trigger-mcp 插件
  • 安装 mcp-rust 创建新MCP组件的模板

验证安装:

spin plugins list
# Should show: trigger-mcp

spin templates list
# Should show: mcp-rust (MCP server component)

2.创建新的MCP工具

使用模板创建新的MCP服务器:

spin new -t mcp-rust my-mcp-server
cd my-mcp-server

这将创建一个项目结构,其中包含:

  • spin.toml -带MCP触发器配置的Spin应用程序清单
  • src/lib.rs -带有MCP组件实现的Rust代码
  • Cargo.toml -Rust依赖项,包括spin-mcp-sdk

生成的 spin.toml 看起来像:

spin_manifest_version = 2

[application]
name = "my-mcp-server"
version = "0.1.0"

[[trigger.mcp]]
component = "my-mcp-server"
route = "/mcp"

[component.my-mcp-server]
source = "target/wasm32-wasip1/release/my_mcp_server.wasm"

[component.my-mcp-server.build]
command = "cargo build --target wasm32-wasip1 --release"

3.实施您的MCP工具

您的组件使用 mcp_component 宏来实现MCP接口:

use spin_mcp_sdk::{mcp_component, Request, Response, Tool, ToolResult, Error};
use serde_json::json;

#[mcp_component]
fn handle_request(request: Request) -> Response {
    match request {
        Request::ToolsList => {
            Response::ToolsList(vec![
                Tool {
                    name: "example_tool".to_string(),
                    description: "An example tool that echoes input".to_string(),
                    input_schema: json!({
                        "type": "object",
                        "properties": {
                            "message": {
                                "type": "string",
                                "description": "Message to echo"
                            }
                        },
                        "required": ["message"]
                    }).to_string(),
                }
            ])
        }
        
        Request::ToolsCall(params) => {
            match params.name.as_str() {
                "example_tool" => {
                    // Parse arguments
                    let args: serde_json::Value = serde_json::from_str(&params.arguments)
                        .unwrap_or(json!({}));
                    
                    let message = args.get("message")
                        .and_then(|v| v.as_str())
                        .unwrap_or("No message provided");
                    
                    Response::ToolsCall(ToolResult::Text(
                        format!("Echo: {}", message)
                    ))
                }
                _ => Response::ToolsCall(ToolResult::Error(Error {
                    code: -32602,
                    message: format!("Unknown tool: {}", params.name),
                    data: None,
                }))
            }
        }
        
        Request::ResourcesList => {
            Response::ResourcesList(vec![])
        }
        
        Request::PromptsList => {
            Response::PromptsList(vec![])
        }
        
        Request::Ping => Response::Pong,
        
        _ => Response::Error(Error {
            code: -32601,
            message: "Method not found".to_string(),
            data: None,
        })
    }
}

4.构建并运行MCP服务器

spin build
spin up

您的MCP服务器现在正在运行 http://localhost:3000/mcp 并且可以由MCP客户端访问。

MCP客户端配置

克劳德桌面

添加到您的Claude Desktop配置中:

{
  "mcpServers": {
    "demo": {
      "url": "http://127.0.0.1:3000/mcp",
      "transport": "http"
    }
  }
}

API直接使用

# List available tools
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'

# Call a tool
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "example_tool",
      "arguments": {"message": "Hello, MCP!"}
    },
    "id": 2
  }'

支持的MCP功能

  • 工具:公开AI模型可以调用的函数
  • 资源:共享文件或数据库模式等数据
  • 鼓励:为AI交互提供提示模板
  • 完整JSON-RPC 2.0:完成协议实施

例子

请参阅 examples/ 完整MCP服务器实现目录:

  • demo-mcp/ -演示MCP基本功能的简单回声工具

要运行演示示例:

cd examples/demo-mcp
spin build
spin up

然后进行测试:

# List tools
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}'

# Call the echo tool
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "example_tool",
      "arguments": {
        "message": "Hello, MCP!"
      }
    },
    "id": 2
  }'

发展

从源头构建

# Clone the repository
git clone https://github.com/fastertools/spin-trigger-mcp
cd spin-trigger-mcp

# Build the plugin
cargo build --release

# Package for distribution
spin pluginify

运行测试

cargo test

许可证

阿帕奇-2.0

目录标签

目录标签

RustClaudeAI工具集成WebAssembly本地部署MCP协议JSON-RPCSpin插件

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

1

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP