使用说明
加油MCP服务器
部署退款
在命名空间reunc系统中部署所有reunc组件。
kubectl apply -f https://raw.githubusercontent.com/refunc/mcp-server/refs/heads/main/deploy/play-all-in-one.yaml
然后代理拒绝本地服务。
kubectl port-forward svc/aws-api 8000:http --address 0.0.0.0 -n refunc-system
kubectl port-forward svc/mcp-server 8001:http --address 0.0.0.0 -n refunc-system
PS:演示部署的数据不是持久的。
创建函数
创建一个函数 拒绝cli.
pip install -U refunc-cli
mkdir mcp-demo && cd mcp-demo
rfctl init
Initing function manifest in /path/mcp-demo/lambda.yaml
Name: mcp-demo
Namespace: refunc-system
Select Language:
1 - python
2 - go
Choose from 1, 2 [1]:
Select Runtime:
1 - python3.10
2 - python3.9
3 - python3.8
Choose from 1, 2, 3 [1]:
# write any code in main.py, the demo is echo a hello msg.
AWS_DEFAULT_ENDPOINT=http://127.0.0.1:8000 rfctl create
PS:你需要一个Python 3环境。
创建MCP端点
按照以下代码编辑lambda.yaml。
metadata:
name: mcp-demo
namespace: refunc-system
spec:
build:
source: .
manifest: requirements.txt
language: python
architecture: x86_64
handler: main.lambda_handler
timeout: 120
runtime: "python3.10"
concurrency: 1
environment:
ENV_TEST: TEST
# url:
# cors:
# allowCredentials: true
# allowHeaders: "*"
# allowMethods: "*"
# allowOrigins: "*"
# exposeHeaders: "*"
# maxAge: 300
events:
# - name: hourly
# type: cron
# mapping:
# cron: 0 * * * *
# location: Asia/Shanghai
# args:
# var1: value1
# saveLog: false
# saveResult: false
- name: mcp
type: mcp
mapping:
args:
token: mcp-demo
tools:
- name: echo-hello
desc: Echo a hello msg #Cannot contain single quotes
schema:
type: object
properties: {}
required: []
saveLog: false
saveResult: false
AWS_DEFAULT_ENDPOINT=http://127.0.0.1:8000 rfctl update-config
演示MCP SSE端点为: http://127.0.0.1:8001/refunc-system/mcp-demo/test/mcp-demo/sse
退款MCP SSE url路径格式为: /namespace/<token-secret-name>/<token>/<func-name>/sse
MCP事件规范
- name: mcp
type: mcp # the event type must be mcp.
mapping:
args:
token: mcp-demo # the token secret name you can find in play-all-in-one.yaml.
tools: # mcp tools
- name: echo-hello # mcp tool name
desc: Echo a hello msg # mcp tool desc
schema: # mcp tool parameters, described with a valid JSON Schema.
type: object
properties: {}
required: []
saveLog: false
saveResult: false
事件的工具字段是一个数据结构,您可以使用一个函数实现多个工具。 调用函数时,refunc将添加两个内置参数:_call_type和_call_method,其中_call_mmethod是工具的名称。
