@codespar/mcp

中文文档
0.5.20发布于 2026/10/31MITTypeScriptES Module构建来源已验证近 30 天下载 2791

MCP server for CodeSpar — give Claude, Codex, Cursor & ChatGPT a commerce agent (pay, charge, wallet, mandates, Pomelo card) over MCP

原始使用文档
文档目录8 节
  1. Run as a server ( codespar-mcp )
  2. Scopes: what the key decides
  3. Use as a config helper (library)
  4. Usage
  5. API
  6. McpConfig
  7. Need more?
  8. License

@codespar/mcp

MCP server for CodeSpar — give Claude, Codex, Cursor, VS Code (and any MCP client) a Latin-American commerce agent: search & checkout, Pix, wallet/balance, spend mandates & limits, and Pomelo card issuing — all as MCP tools.

Run as a server (codespar-mcp)

A stdio MCP server that bridges your MCP client to a CodeSpar session's tools. It talks to the CodeSpar REST API directly, so it works against the live meta-tools today (codespar_pay, codespar_charge, codespar_discover, wallet, mandates, and codespar_issue → Pomelo card). One env var (CODESPAR_API_KEY) and you're in.

Claude Code / Claude Desktop

claude mcp add codespar -- npx -y @codespar/mcp
# then set CODESPAR_API_KEY in the server's env

Codex — ~/.codex/config.toml:

[mcp_servers.codespar]
command = "npx"
args = ["-y", "@codespar/mcp"]
env = { CODESPAR_API_KEY = "csk_live_...", CODESPAR_PRESET = "brazilian" }

Cursor / VS Code — { "command": "npx", "args": ["-y", "@codespar/mcp"], "env": { "CODESPAR_API_KEY": "csk_live_..." } }

Config (env or --flag): CODESPAR_API_KEY (required), CODESPAR_PROJECT (prj_…), CODESPAR_PRESET (brazilian|mexican|argentinian|colombian|all, default brazilian), CODESPAR_SERVERS (comma list, overrides preset), CODESPAR_USER_ID.

Scopes: what the key decides

The API enforces every scope; this server widens nothing. At boot it opens a session, and the answer decides what tools/list offers:

Answer to POST /v1/sessionsWhat the server does
sessionthe session's commerce tools (codespar_pay, codespar_charge, codespar_discover, wallet, mandates, Shop purchases) plus codespar_payables and codespar_documents
403 (valid key without sessions:create)no session: only codespar_payables and codespar_documents, which run over REST; a session tool called by name answers that the key lacks sessions:create

A document (codespar_documents, or a codespar_wallet receipt_document / statement_document) comes back as its JSON reference plus the document itself: a receipt's PNG as an image block, a statement's pages as PNG image blocks (25 lines each, at most 8), a PDF as an embedded resource (codespar://documents/…), up to 4 MiB each. A statement page that could not be fetched is named in the text. | 401 (wrong, revoked or other-environment key) | setup mode |

ToolsScope the key needs
session toolssessions:create (and tools:execute to call them)
codespar_payables upload, create_batch, get, update_item, set_rail, discardpayables:read / payables:write
codespar_payables paypayables:pay

Inside codespar_payables, a 403 is rendered as insufficient permission (403): … with the API's message naming the scope, and a 401 as credential invalid or revoked (401): …, so an agent never retries a missing scope as a broken key.

Use as a config helper (library)

npm install @codespar/mcp @codespar/sdk

Usage

import { CodeSpar } from "@codespar/sdk";
import { getMcpConfig, getClaudeDesktopConfig } from "@codespar/mcp";

const cs = new CodeSpar({ apiKey: "ak_..." });
// Optionally pin to a project: new CodeSpar({ apiKey: "ak_...", projectId: "prj_..." })
const session = await cs.create("user_123", { preset: "brazilian" });

// Get MCP URL and headers for any client
const { url, headers } = getMcpConfig(session);

// Get Claude Desktop config JSON
const config = getClaudeDesktopConfig(session);

The session itself also exposes the meta-tool router wrappers — session.discover(query), session.connectionWizard({...}), session.paymentStatus(toolCallId) — for tool search, connect deep-links, and async settlement correlation.

API

FunctionSignatureDescription
getMcpConfig(session: Session) => McpConfigGet the MCP transport URL and headers for any MCP-compatible client
getClaudeDesktopConfig(session: Session, serverName?: string) => { mcpServers: ... }Generate Claude Desktop configuration (for claude_desktop_config.json)
getCursorConfig(session: Session) => { url: string; headers: Record<string, string> }Generate Cursor / VS Code MCP configuration

McpConfig

PropertyTypeDescription
urlstringMCP transport URL
headersRecord<string, string>Auth headers for the transport

Need more?

Need governance, budget limits, and audit trails for agent payments? CodeSpar Enterprise adds policy engine, payment routing, and compliance templates on top of these MCP servers.

License

MIT — codespar.dev

版本与发布记录

@codespar/mcp 共发布 23 个版本,首次发布于 2026/04/15;过去 12 个月发布了 23 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.20latest2026/10/3110 天前
0.5.192026/10/3010 天前
0.5.182026/10/3010 天前
0.5.152026/10/2812 天前
0.5.142026/10/2813 天前
0.5.132026/10/2713 天前

关于 @codespar/mcp 的常见问题

@codespar/mcp 是什么?

MCP server for CodeSpar — give Claude, Codex, Cursor & ChatGPT a commerce agent (pay, charge, wallet, mandates, Pomelo card) over MCP

如何安装 @codespar/mcp?

在项目目录运行 npm install @codespar/mcp,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@codespar/sdk(^0.10.1 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0 || ^0.15.0 || ^0.16.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 codespar-mcp,可以用 npx codespar-mcp 直接运行。

@codespar/mcp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codespar/mcp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@codespar/mcp 可以商用吗?

@codespar/mcp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codespar/mcp 的下载量有多少?

根据 npm 官方下载统计,@codespar/mcp 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,791 次,日均约 93 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codespar/mcp 还在维护吗?

最新版本 0.5.20 发布于 2026/10/31(10 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/04/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。