FluidSDK MCP 服务器
FluidSDK代理的生产就绪模型上下文协议服务器。部署到Vercel、AWS或任何Node.js托管平台。
特性
- ✅ 4工具:计算、获取天气、回声、获取时间戳
- ✅ 3提示:问候语、代码审查、调试助理
- ✅ 4资源:配置、状态、docs/api、docs/quickstart
- ✅ HTTP/SSE支持:生产就绪,服务器已发送事件
- ✅ CORS已启用:已准备好处理跨来源请求
- ✅ 健康检查:内置健康和状态端点
- ✅ TypeScript:全型安全
- ✅ Vercel准备就绪:一键部署
快速开始
地方发展
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Start production server
npm start服务器将在上运行 http://localhost:3000
测试服务器
# Check server info
curl http://localhost:3000/
# Health check
curl http://localhost:3000/health
# Get detailed info
curl http://localhost:3000/infoAPI终点
得到/
服务器信息和功能概述
{
"name": "FluidSDK MCP Server",
"version": "1.0.0",
"status": "healthy",
"endpoints": {
"mcp": "/mcp",
"health": "/health",
"info": "/info"
},
"capabilities": {
"tools": [...],
"prompts": [...],
"resources": [...]
}
}GET/健康
用于监控的健康检查端点
{
"status": "healthy",
"uptime": 123.456,
"timestamp": "2025-11-11T08:00:00.000Z"
}获取/信息
详细的服务器信息和功能
POST/mcp
使用服务器发送事件(SSE)的主MCP协议端点
能力
工具(可执行函数)
- 计算
- 执行数学运算(加、减、乘、除) - 输入: { operation, a, b } - 输出:计算结果
- get_weather
- 获取某个位置的天气信息 - 输入: { location, unit? } - 输出:天气数据(模拟)
- 回声
- 回显消息 - 输入: { message } - 输出:回声消息
- 获取时间戳
- 获取各种格式的当前时间戳 - 输入: { format? } - 输出:格式化时间戳
提示(模板)
- 问候
- 生成个性化问候 - Args: name, time_of_day
- 代码查看
- 代码审查请求模板 - Args: language, complexity
- debug_assistant
- 调试协助提示 - Args: error_type
资源(数据访问)
- fluidsdk://config -服务器配置
- fluidsdk://status -实时服务器状态
- fluidsdk://docs/api -API文件
- fluidsdk://docs/quickstart -快速入门指南
部署到Vercel
选项1:Vercel CLI
# Install Vercel CLI
npm i -g vercel
# Deploy
cd mcp-server
vercel选项2:GitHub集成
- 将此文件夹推送到GitHub
- 在Vercel仪表板中导入存储库
- 将根目录设置为
mcp-server - 部署!
环境变量(可选)
PORT=3000 # Port number (default: 3000)部署到其他平台
Heroku
# Create Heroku app
heroku create your-mcp-server
# Deploy
git subtree push --prefix mcp-server heroku mainAWS Lambda/API网关
使用无服务器框架或AWS SAM作为Lambda函数进行部署。
码头工人
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY dist ./dist
EXPOSE 3000
CMD ["node", "dist/index.js"]使用FluidSDK
import { FluidSDK } from "fluidsdk";
// Create agent with your deployed MCP server
const agent = sdk.createAgent("My Agent", "Description", "image");
await agent.setMCP("https://your-mcp-server.vercel.app/mcp");
await agent.registerIPFS();
// Agent is now discoverable with MCP capabilities!使用MCP客户端进行测试
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
const transport = new SSEClientTransport(
new URL("https://your-mcp-server.vercel.app/mcp")
);
const client = new Client({
name: "test-client",
version: "1.0.0",
}, { capabilities: {} });
await client.connect(transport);
// List tools
const tools = await client.listTools();
console.log(tools);
// Call a tool
const result = await client.callTool({
name: "calculate",
arguments: { operation: "add", a: 10, b: 20 }
});
console.log(result);项目结构
mcp-server/
├── src/
│ ├── index.ts # Express server with HTTP/SSE
│ └── server.ts # MCP server core logic
├── dist/ # Compiled JavaScript (generated)
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── vercel.json # Vercel deployment config
└── README.md # This file发展
添加新工具
编辑 src/server.ts 并添加到工具数组中:
{
name: "your_tool",
description: "Tool description",
inputSchema: {
type: "object",
properties: { ... },
required: [...]
}
}然后在中实现处理程序 handleTool 方法。
添加新提示
添加到提示数组中并在中实现处理程序 handlePrompt 方法。
添加新资源
添加到资源数组并在中实现处理程序 handleResource 方法。
监控
部署后,监控您的服务器:
# Check health
curl https://your-mcp-server.vercel.app/health
# View logs (Vercel)
vercel logs
# View metrics (Vercel Dashboard)
# Analytics → Functions → /mcp安全
对于生产部署:
- 添加身份验证:实现API密钥或OAuth
- 速率限制:使用中间件防止滥用
- 输入验证:验证所有工具输入
- CORS配置:根据需要限制来源
- 错误处理:不要暴露敏感的错误详细信息
API密钥示例:
app.use((req, res, next) => {
const apiKey = req.headers['x-api-key'];
if (apiKey !== process.env.API_KEY) {
return res.status(401).json({ error: 'Unauthorized' });
}
next();
});支持
- 文档:https://docs.fluidsdk.io
- GitHub问题:https://github.com/yourusername/fluidsdk
- 不一致:https://discord.gg/fluidsdk
许可证
麻省理工学院
