WebAssembly组件服务器模板

用于创建基于Model Context Protocol (MCP)的WebAssembly组件服务器的模板,支持wasmCloud平台。

  • by controlmcp
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 controlmcp/mcp-server-template-ts

使用说明

mcp服务器模板

用于创建WebAssembly组件的模板存储库 模型上下文协议(MCP) 服务器, 随着 wasmCloud.

依赖项

快速启动

启动开发循环

构建组件:

npm install
npm run dev

要调试您的组件,我们建议使用 官方MCP模型检查员, 要运行,您可以运行:

npm run inspector

使用模型检查器,您可以通过HTTP连接到本地MCP服务器, 操作资源、运行工具等。

从我们的模板生成MCP服务器

1.使用我们的插件使用此模板从openapi生成

wash plugin install ghcr.io/cosmonic-labs/plugins/openapi2mcp:0.2.0

mkdir petstore
cd petstore
curl -fLO https://petstore3.swagger.io/api/v3/openapi.json
wash openapi2mcp openapi.json

# modify src/constants.ts
# point to the service (they don't set the server url in this openapi doc):
code generated
export const BASE_URL = "https://petstore3.swagger.io/api/v3";

wash dev

设置宇宙控制

一旦您的MCP服务器准备好进入黄金时段,请确保 Comonic 群集正在运行。

Don't have a Comsonic cluster set up?

首先,注册一个 免费宇宙许可证.

一旦你有了许可证密钥,你就可以在任何Kubernetes集群上设置一个Cosmonic集群 支持Helm:

helm install cosmonic-control oci://ghcr.io/cosmonic/cosmonic-control \
  --version 0.2.0 \
  --namespace cosmonic-system \
  --create-namespace \
  --set cosmonicLicenseKey="<insert license here>"

helm install hostgroup oci://ghcr.io/cosmonic/cosmonic-control-hostgroup --version 0.2.0 --namespace cosmonic-system --set http.enabled=true

部署应用程序

操作员启动并运行后,我们可以启动 HostGroup,这是一组 wasmCloud 配置为协同工作的实例。

使用Helm CLI

# Note substitue your own pushed image
helm install weather-gov-mcp oci://ghcr.io/cosmonic-labs/charts/http-sample \
  -n weather-gov --create-namespace \
  --set component.image=ghcr.io/cosmonic-labs/components/weather-gov-mcp:0.1.0 \
  --set component.name=weather-gov-mcp 

连接到已部署的MCP服务器

如果使用k8s集群运行,则可以向前移植:

kubectl -n cosmonic-system port-forward svc/hostgroup-default 9091:9091

一旦你为你的宇宙控制集群配置了本地端口转发, 使用 官方MCP模型检查员 连接。

您可以通过以下命令启动MCP检查器:

npm run inspector