Skip to main content
REST client

MCP Servers

The 8 operations under mcp-servers, as typed calls on the generated REST client.

1 min read
View MarkdownEdit on GitHub

MCP Servers

Available from @codespar/sdk 0.12.0, which is not on npm yet. The published version today is 0.11.0, and it has no cs.api; 0.12.0 is on the main branch of codespar-core. The examples below are not compiled against the installed package for that reason.

Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.

import { CodeSpar } from "@codespar/sdk";

const cs = new CodeSpar({ apiKey: process.env.CODESPAR_API_KEY });

GET /v1/mcp-servers

GET/v1/mcp-servers

List this project's MCP servers

const result = await cs.api.get("/v1/mcp-servers");

Parameters, body and every documented response: GET /v1/mcp-servers in the HTTP reference.

POST /v1/mcp-servers

POST/v1/mcp-servers

Register a monetized MCP server and price its tools

const r = await cs.api.response("post", "/v1/mcp-servers", {
  body: {
    slug: "example",
    name: "Example",
    description: "string",
    overview_md: "string",
    category: "string",
    upstream_url: "https://example.com/hook",
    consumer_id: "csm_0000000000000000",
    upstream_auth: {
      header: "string",
      value: "string"
    },
    platform_fee_bps: 0,
    tools: [
      {
        tool_name: "Example",
        description: "string",
        price: "string"
      }
    ]
  }
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}

Parameters, body and every documented response: POST /v1/mcp-servers in the HTTP reference.

POST /v1/mcp-servers/platform-fees/sweep

POST/v1/mcp-servers/platform-fees/sweep
Moves money

This moves everything unswept for the calling organization to its provisioned platform wallet

Move accrued platform fees to the organization's wallet now

const r = await cs.api.response("post", "/v1/mcp-servers/platform-fees/sweep");
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}

Parameters, body and every documented response: POST /v1/mcp-servers/platform-fees/sweep in the HTTP reference.

POST /v1/mcp-servers/validate

POST/v1/mcp-servers/validate

Connect to an upstream MCP server and list its tools

const r = await cs.api.response("post", "/v1/mcp-servers/validate", {
  body: {
    upstream_url: "https://example.com/hook",
    auth: {
      header: "string",
      value: "string"
    }
  }
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}

Parameters, body and every documented response: POST /v1/mcp-servers/validate in the HTTP reference.

GET /v1/mcp-servers/{id}

GET/v1/mcp-servers/{id}

Read one MCP server with its priced tools

const result = await cs.api.get("/v1/mcp-servers/{id}", {
  path: {
    id: "msrv_0000000000000000"
  }
});

Parameters, body and every documented response: GET /v1/mcp-servers/{id} in the HTTP reference.

PATCH /v1/mcp-servers/{id}

PATCH/v1/mcp-servers/{id}

Update an MCP server's listing metadata or its active flag

const r = await cs.api.response("patch", "/v1/mcp-servers/{id}", {
  path: {
    id: "msrv_0000000000000000"
  },
  body: {
    name: "Example",
    description: "string",
    overview_md: "string",
    category: "string",
    active: true
  }
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}

Parameters, body and every documented response: PATCH /v1/mcp-servers/{id} in the HTTP reference.

DELETE /v1/mcp-servers/{id}

DELETE/v1/mcp-servers/{id}

Delete an MCP server and its priced tools

const r = await cs.api.response("delete", "/v1/mcp-servers/{id}", {
  path: {
    id: "msrv_0000000000000000"
  }
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}

Parameters, body and every documented response: DELETE /v1/mcp-servers/{id} in the HTTP reference.

PATCH /v1/mcp-servers/{id}/tools/{tool}

PATCH/v1/mcp-servers/{id}/tools/{tool}

Reprice one tool, or turn it off

const r = await cs.api.response("patch", "/v1/mcp-servers/{id}/tools/{tool}", {
  path: {
    id: "msrv_0000000000000000",
    tool: "string"
  },
  body: {
    price: "string",
    active: true
  }
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}

Parameters, body and every documented response: PATCH /v1/mcp-servers/{id}/tools/{tool} in the HTTP reference.

MCP Servers | CodeSpar