HomeInicio/Docs/MCP integrationIntegración MCP
Model Context ProtocolModel Context Protocol
MCP Integration
Integración MCP
Pacta ships a Model Context Protocol server so any MCP-capable agent - Claude, or any other MCP client - can transact on the marketplace with 12 tools: discover services, contract, fund escrow, verify registry proofs, release payment, and rate the provider.
Pacta incluye un servidor Model Context Protocol para que cualquier agente compatible con MCP - Claude, o cualquier otro cliente MCP - pueda operar en el marketplace con 12 herramientas: descubrir servicios, contratar, depositar en garantía, verificar pruebas del registro, liberar el pago y calificar al proveedor.
Quick start
Inicio rápido
Prerequisites: Node ≥ 22.5 and a running marketplace. Start the Pacta marketplace (staking and registry verification on):
Requisitos: Node ≥ 22.5 y un marketplace en ejecución. Levanta el marketplace Pacta (con staking y verificación de registro activos):
npm run start:pacta # serves the marketplace at http://localhost:3220
Then run the MCP server over stdio. Two environment variables configure it: MARKETPLACE_URL and AGENT_ID.
Luego ejecuta el servidor MCP sobre stdio. Dos variables de entorno lo configuran: MARKETPLACE_URL y AGENT_ID.
MARKETPLACE_URL=http://localhost:3220 AGENT_ID=1 node mcp/server.js
MARKETPLACE_URL defaults to http://localhost:3000 in the source - set it to your marketplace URL (for the Pacta server above, http://localhost:3220). AGENT_ID defaults to 1; it identifies the buying agent whose balance funds escrow.
MARKETPLACE_URL tiene por defecto http://localhost:3000 en el código - ajústalo a la URL de tu marketplace (para el servidor Pacta de arriba, http://localhost:3220). AGENT_ID tiene por defecto 1; identifica al agente comprador cuyo saldo fondea la custodia.
Connect Claude
Conectar Claude
Write an MCP config file that declares the marketplace server. This is exactly the shape the agent demo generates:
Crea un archivo de configuración MCP que declare el servidor del marketplace. Esta es exactamente la forma que genera la demo del agente:
{
"mcpServers": {
"marketplace": {
"command": "node",
"args": ["mcp/server.js"],
"env": {
"MARKETPLACE_URL": "http://localhost:3220",
"AGENT_ID": "1"
}
}
}
}
Then point the claude CLI at that config and allow the marketplace tools:
Después apunta la CLI de claude a esa configuración y permite las herramientas del marketplace:
claude -p "<your mission>" \
--mcp-config path/to/config.json \
--allowedTools "mcp__marketplace__*"
Or run the packaged one-command demos, which start a fresh marketplace, a provider bot, and the buying agent on port 3230: npm run demo:agent runs a deterministic MCP client (no API key), and npm run demo:agent:claude drives the same tools with a real Claude agent.
O ejecuta las demos empaquetadas de un solo comando, que levantan un marketplace nuevo, un bot proveedor y el agente comprador en el puerto 3230: npm run demo:agent usa un cliente MCP determinista (sin API key), y npm run demo:agent:claude maneja las mismas herramientas con un agente Claude real.
The 12 tools
Las 12 herramientas
Every tool is prefixed mcp__marketplace__ when exposed to the agent. They map 1:1 to the marketplace REST API and return trimmed JSON. Grouped here in lifecycle order.
Cada herramienta lleva el prefijo mcp__marketplace__ cuando se expone al agente. Corresponden 1:1 a la API REST del marketplace y devuelven JSON reducido. Aquí van agrupadas en orden de ciclo de vida.
Discovery
Descubrimiento
search_offers
Search the marketplace for real-world services offered by vetted SMBs. Results are ranked by provider rating, then price.
Busca en el marketplace servicios del mundo real ofrecidos por pymes verificadas. Los resultados se ordenan por calificación del proveedor y luego por precio.
query: string (required) · category: string (optional - legal | tourism | real-estate | accounting)query: string (obligatorio) · category: string (opcional - legal | tourism | real-estate | accounting)
get_offer
Full detail of one offer: fulfillment steps, escrow terms and provider profile.
Detalle completo de una oferta: pasos de cumplimiento, términos de garantía y perfil del proveedor.
offer_id: integer
get_my_balance
Your current simulated USD balance.
Tu saldo simulado actual en USD.
no parameterssin parámetros
Contracting
Contratación
create_engagement
Create a draft contract from an offer. The offer steps are snapshotted; nothing is binding or paid yet.
Crea un contrato en borrador a partir de una oferta. Los pasos de la oferta se congelan; todavía nada es vinculante ni está pagado.
offer_id: integer
agree_to_contract
Lock the engagement terms and steps into an immutable contract (draft → agreed). After this, steps cannot be modified by anyone.
Fija los términos y pasos del contrato en un acuerdo inmutable (borrador → acordado). Después de esto, nadie puede modificar los pasos.
engagement_id: integer
fund_escrow
Move the agreed downpayment from your balance into the engagement escrow account. The provider cannot start work before this.
Traslada el anticipo acordado desde tu saldo a la cuenta de garantía del contrato. El proveedor no puede empezar a trabajar antes de esto.
engagement_id: integer
Fulfillment
Cumplimiento
get_engagement
Current state of an engagement: steps, proofs, platform verification flags, and escrow balance.
Estado actual de un contrato: pasos, pruebas, indicadores de verificación de la plataforma y saldo en garantía.
engagement_id: integer
wait_for_provider_submission
Block until the provider finishes all steps and submits the engagement for your verification (or time out). Use after funding escrow.
Se bloquea hasta que el proveedor termina todos los pasos y envía el contrato para tu verificación (o expira el tiempo). Úsala después de financiar la garantía.
engagement_id: integer · timeout_seconds: integer 1–120 (optional, default 60)engagement_id: integer · timeout_seconds: integer 1–120 (opcional, por defecto 60)
Verification & settlement
Verificación y liquidación
verify_registry_reference
Independently verify a proof against the public registry (company registry, municipal permits, tax authority). Returns the official record or an error if it does not exist.
Verifica de forma independiente una prueba contra el registro público (registro mercantil, permisos municipales, autoridad tributaria). Devuelve el registro oficial o un error si no existe.
ref: string (e.g. CR-RN-2026-104512)ref: string (p. ej. CR-RN-2026-104512)
approve_and_release_payment
Accept the delivered proofs. Draws the remaining balance from your account and releases the FULL price to the provider. Irreversible - verify the proofs first.
Acepta las pruebas entregadas. Retira el saldo restante de tu cuenta y libera el precio COMPLETO al proveedor. Irreversible - verifica las pruebas primero.
engagement_id: integer
reject_and_open_dispute
Reject the delivered proofs with a reason. Escrow is held and a neutral arbiter will rule (release / refund / split). The provider risks its stake.
Rechaza las pruebas entregadas con un motivo. La garantía queda retenida y un árbitro neutral decidirá (liberar / reembolsar / dividir). El proveedor arriesga su colateral.
engagement_id: integer · reason: stringengagement_id: integer · reason: string
Reputation
Reputación
rate_provider
Rate the provider after settlement (good or bad). Ratings are tied to real settled money and drive search ranking.
Califica al proveedor tras la liquidación (bueno o malo). Las calificaciones están ligadas a dinero realmente liquidado e influyen en el orden de búsqueda.
engagement_id: integer · value: "good" | "bad"engagement_id: integer · value: "good" | "bad"
A typical session
Una sesión típica
The tools are meant to be called in lifecycle order. A full purchase looks like this:
Las herramientas están pensadas para llamarse en orden de ciclo de vida. Una compra completa se ve así:
# 1. Discover a suitable vetted provider
search_offers({ query: "Costa Rica company hotel", category: "legal" })
get_offer({ offer_id: 7 }) # review steps, escrow terms, provider profile
# 2. Contract and fund
create_engagement({ offer_id: 7 }) # draft → returns engagement_id, e.g. 12
agree_to_contract({ engagement_id: 12 }) # draft → agreed (steps now immutable)
fund_escrow({ engagement_id: 12 }) # moves the downpayment into escrow
# 3. Wait for the provider to deliver
wait_for_provider_submission({ engagement_id: 12, timeout_seconds: 120 })
# 4. Verify EVERY registry-anchored proof before releasing money
verify_registry_reference({ ref: "CR-RN-2026-104512" }) # company registry
verify_registry_reference({ ref: "CR-MUNI-2026-77310" }) # municipal permit
# 5. Settle - only if all proofs check out
approve_and_release_payment({ engagement_id: 12 }) # releases the full price
rate_provider({ engagement_id: 12, value: "good" })
approve_and_release_payment is irreversible: it pays the provider the full price and cannot be undone. Always call verify_registry_reference on every registry-anchored proof first, and confirm the record kind matches what the step required. If any proof fails to verify, use reject_and_open_dispute with a reason instead of approving.
approve_and_release_payment es irreversible: paga al proveedor el precio completo y no se puede deshacer. Llama siempre primero a verify_registry_reference en cada prueba anclada al registro, y confirma que el tipo de registro coincide con lo que exigía el paso. Si alguna prueba no se verifica, usa reject_and_open_dispute con un motivo en lugar de aprobar.
Errors
Errores
When the marketplace rejects a call, the tool returns an MCP error result (isError) whose text carries the HTTP status and message from the marketplace - for example 409 when a state transition is illegal (funding an engagement that is not yet agreed), or 404 for an unknown registry reference. Read the message, correct the request, and retry.
Cuando el marketplace rechaza una llamada, la herramienta devuelve un resultado de error MCP (isError) cuyo texto lleva el estado HTTP y el mensaje del marketplace - por ejemplo 409 cuando una transición de estado es inválida (financiar un contrato que aún no está acordado), o 404 para una referencia de registro desconocida. Lee el mensaje, corrige la solicitud y reintenta.