文档
MCP配置
MCP 连接配置 CRUD 和服务器信息请求。
从英文自动翻译。 查看英文原文
将这些请求发送到您自己正在运行的 sidecar。值保留在此浏览器中。
这是如何运作的
sidecar 侦听启动时选择的环回端口并将其打印在其中 ready 线;使用该 URL 和 CADCAMFUN_TOKEN 它是从开始的。请求直接从该页面发送到该地址。
sidecar 仅将 CORS 标头发送到 Tauri 源并发送到 http://localhost 或 http://127.0.0.1 在任何端口上。浏览器会阻止托管文档的响应,因此请在本地运行文档(bun run dev 中 packages/web) 使用游乐场,或将请求复制为curl。要在不接触真实数据的情况下进行实验,请使用以下命令启动 sidecar CADCAMFUN_DATA_DIR 指向一个一次性目录 - 请参阅 aPI 演练.
运营
8 个端点,位于 mcp 组,由 sidecar 自己生成 开放API文档。受保护的操作需要 Authorization: Bearer $CADCAMFUN_TOKEN;看 验证。行为和限制在 子系统指南.
| 得到 | /api/mcp/config | mcp.listConfig |
| 邮政 | /api/mcp/config | mcp.createConfig |
| 放 | /api/mcp/config | mcp.updateConfig |
| 删除 | /api/mcp/config | mcp.removeConfig |
| 得到 | /api/mcp/config/{id} | mcp.getConfig |
| 放 | /api/mcp/config/{id} | mcp.updateConfigById |
| 删除 | /api/mcp/config/{id} | mcp.removeConfigById |
| 邮政 | /api/mcp/server-info | mcp.serverInfo |
/api/mcp/config
mcp.listConfig 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| 来源 | 询问 | 细绳 | null | 选修的 |
200 对象|目的 application/json
{ success: true source: "claude" | "database" servers: Array<{ id: string name: string type: string url: string | null command: string | null args: unknown workingDirectory: string | null enabled: boolean userId: string | null createdAt: string updatedAt: string }> count: number | "Infinity" | "-Infinity" | "NaN" } | { success: true source: "file" config: { mcpServers: Array<{ id: string name: string type: string url: string | null command: string | null args: unknown workingDirectory: string | null enabled: boolean }> } exportedAt: string }
400 McpEnvBadRequestEncoded application/json
McpEnvBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 McpEnvInternalEncoded application/json
McpEnvInternalEncoded
响应示例 捕获·200
{
"success": true,
"source": "claude",
"servers": [],
"count": 0
} SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// McpListConfigInput
const result = await client.mcp.listConfig({}) curl
curl --request GET "${CADCAMFUN_URL}/api/mcp/config" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
mcp.createConfig 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| 来源 | 询问 | 细绳 | null | 选修的 |
{ id?: string | null name?: string | null type?: string | null url?: string | null command?: string | null args?: unknown | null workingDirectory?: string | null defaultWorkingDirectory?: string | null enabled?: boolean | null serverName?: string | null testConnection?: boolean | null mcpServers?: unknown | null tool_configuration?: unknown | null authorization_token?: string | null }
200 目的 application/json
{ success: true source: "file" imported: number | "Infinity" | "-Infinity" | "NaN" message: string }
201 目的 application/json
{ success: true source: "claude" | "database" server: { id: string name: string type: string url: string | null command: string | null args: unknown workingDirectory: string | null enabled: boolean userId: string | null createdAt: string updatedAt: string } connectionTest?: unknown | null message: string }
400 McpEnvBadRequestEncoded application/json
McpEnvBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 McpEnvInternalEncoded application/json
McpEnvInternalEncoded
获取示例
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/mcp/config`, {
method: "POST",
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
}) curl
curl --request POST "${CADCAMFUN_URL}/api/mcp/config" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
mcp.updateConfig 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| 来源 | 询问 | 细绳 | null | 选修的 |
{ id?: string | null name?: string | null type?: string | null url?: string | null command?: string | null args?: unknown | null workingDirectory?: string | null defaultWorkingDirectory?: string | null enabled?: boolean | null serverName?: string | null testConnection?: boolean | null mcpServers?: unknown | null tool_configuration?: unknown | null authorization_token?: string | null }
200 目的 application/json
{ success: true source: "claude" server: { id: string name: string type: string url: string | null command: string | null args: unknown workingDirectory: string | null enabled: boolean userId: string | null createdAt: string updatedAt: string } message: string }
400 McpEnvBadRequestEncoded application/json
McpEnvBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 McpEnvNotFoundEncoded application/json
McpEnvNotFoundEncoded
405 McpEnvMethodNotAllowedEncoded application/json
McpEnvMethodNotAllowedEncoded
500 McpEnvInternalEncoded application/json
McpEnvInternalEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// McpUpdateConfigInput
const result = await client.mcp.updateConfig({
id: "",
name: "",
type: "",
url: "",
command: "",
args: null,
workingDirectory: "",
defaultWorkingDirectory: "",
enabled: false,
serverName: "",
testConnection: false,
mcpServers: null,
tool_configuration: null,
authorization_token: ""
}) curl
curl --request PUT "${CADCAMFUN_URL}/api/mcp/config" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
mcp.removeConfig 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| 来源 | 询问 | 细绳 | null | 选修的 |
| 姓名 | 询问 | 细绳 | null | 选修的 |
200 目的 application/json
{ success: true source: "claude" message: string note: string }
400 McpEnvBadRequestEncoded application/json
McpEnvBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 McpEnvNotFoundEncoded application/json
McpEnvNotFoundEncoded
405 McpEnvMethodNotAllowedEncoded application/json
McpEnvMethodNotAllowedEncoded
500 McpEnvInternalEncoded application/json
McpEnvInternalEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// McpRemoveConfigInput
const result = await client.mcp.removeConfig({}) curl
curl --request DELETE "${CADCAMFUN_URL}/api/mcp/config" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
mcp.getConfig 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
200 目的 application/json
{ id: string name: string type: string url: string | null command: string | null args: unknown workingDirectory: string | null enabled: boolean userId: string | null createdAt: string updatedAt: string }
400 McpBadRequestEncoded application/json
McpBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 McpNotFoundEncoded application/json
McpNotFoundEncoded
500 McpInternalEncoded application/json
McpInternalEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// McpGetConfigInput
const result = await client.mcp.getConfig({
id: "<id>"
}) curl
curl --request GET "${CADCAMFUN_URL}/api/mcp/config/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
mcp.updateConfigById 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
{ id?: string | null name?: string | null type?: string | null url?: string | null command?: string | null args?: unknown | null workingDirectory?: string | null defaultWorkingDirectory?: string | null enabled?: boolean | null serverName?: string | null testConnection?: boolean | null mcpServers?: unknown | null tool_configuration?: unknown | null authorization_token?: string | null }
200 目的 application/json
{ id: string name: string type: string url: string | null command: string | null args: unknown workingDirectory: string | null enabled: boolean userId: string | null createdAt: string updatedAt: string }
400 McpBadRequestEncoded application/json
McpBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 McpNotFoundEncoded application/json
McpNotFoundEncoded
405 McpMethodNotAllowedEncoded application/json
McpMethodNotAllowedEncoded
500 McpInternalEncoded application/json
McpInternalEncoded
获取示例
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/mcp/config/${id}`, {
method: "PUT",
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
}) curl
curl --request PUT "${CADCAMFUN_URL}/api/mcp/config/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
mcp.removeConfigById 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
204 <无内容>
400 McpBadRequestEncoded application/json
McpBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 McpNotFoundEncoded application/json
McpNotFoundEncoded
405 McpMethodNotAllowedEncoded application/json
McpMethodNotAllowedEncoded
500 McpInternalEncoded application/json
McpInternalEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// McpRemoveConfigByIdInput
const result = await client.mcp.removeConfigById({
id: "<id>"
}) curl
curl --request DELETE "${CADCAMFUN_URL}/api/mcp/config/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
/api/mcp/server-info
mcp.serverInfo 需要 Authorization: Bearer <token>.
{ serverId?: string | null }
200 目的 application/json
{ name: string version?: string | null instructions?: string | null resources?: Array<{ name: string uriTemplate?: string | null description?: string | null arguments?: Array<{ name: string description?: string | null required?: boolean | null }> | null }> | null tools?: Array<{ name: string description?: string | null parameters?: unknown | null }> | null }
400 McpBadRequestEncoded application/json
McpBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 McpNotFoundEncoded application/json
McpNotFoundEncoded
405 McpMethodNotAllowedEncoded application/json
McpMethodNotAllowedEncoded
500 McpInternalEncoded application/json
McpInternalEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// McpServerInfoInput
const result = await client.mcp.serverInfo({
serverId: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/mcp/server-info" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
模式
可从该组的参数、主体和响应访问命名模式。一个 ? 标记可选字段; | null 标记可能存在空值的字段。
McpBadRequestEncoded{ _tag: "McpBadRequest" error: string }
McpEnvBadRequestEncoded{ _tag: "McpEnvBadRequest" success: false error: string }
McpEnvInternalEncoded{ _tag: "McpEnvInternal" success: false error: string }
McpEnvMethodNotAllowedEncoded{ _tag: "McpEnvMethodNotAllowed" success: false error: string }
McpEnvNotFoundEncoded{ _tag: "McpEnvNotFound" success: false error: string }
McpInternalEncoded{ _tag: "McpInternal" error: string }
McpMethodNotAllowedEncoded{ _tag: "McpMethodNotAllowed" error: string }
McpNotFoundEncoded{ _tag: "McpNotFound" error: string }
呼叫该群组
操作 ID 的形式为 mcp.<name>。生成的Promise SDK(@cadcamfun/api/sdk)将其中大部分暴露为 client.<namespace>.<method>(input), 在哪里 input 是路径参数和主体字段的一个平面对象;每张卡的 SDK 示例显示了确切的访问器和输入类型。不会生成分段上传、二进制或 JavaScript 响应以及原始 Webhook;这些卡片显示 fetch 改为。
import { CadCam, ClientError } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
try {
await client.projects.list()
} catch (error) {
if (error instanceof ClientError) {
// Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
} else {
// a declared error body: switch on error._tag
}
} 故障排除
| 症状 | 可能的原因 | 使固定 |
|---|---|---|
| 每次调用 401 | 上次启动的令牌或丢失 Bearer 前缀 | 发送 Authorization: Bearer <token> 使用边车启动时的令牌。 |
| 在任何事情发生之前的 400 | 主体或参数与架构不匹配 | 将有效负载与卡上的请求架构进行比较。 |
| 在别处可见的记录上出现 403 或 404 | 代理账户不同 | 发送正确的 x-session-token,或使用拥有该记录的本地配置文件。 |
| 409 | 状态冲突,例如重复的名称或过时的分支头 | 重新读取资源并使用当前数据重试。 |
| 尝试显示“被 CORS 阻止” | 这些文档是从非环回源提供的 | 在本地运行文档或将请求复制为curl。 |
| 连接被拒绝 | Sidecar 在新端口上重新启动 | 从新读取端口 ready 行。 |