MCPClient with Streamable HTTP transport. Mastra’s MCP client exposes all discovered tools directly to a Mastra Agent.
Prerequisites
- Node.js 20+
- A Civic account at nexus.civic.com with a configured toolkit
- A Civic token and an Anthropic API key
Installation
Environment Variables
Get Your Credentials
How to generate a Civic token and configure toolkit URL parameters
Connecting to Civic
UseMCPClient with the servers config, then call listToolsets() to get all tools:
Use
civicMcp.listToolsets() — not civicMcp.getTools(). Merge the returned toolsets object with Object.values(toolsets).reduce((acc, ts) => ({ ...acc, ...ts }), {}) before passing to the agent.Running the Agent
Production Configuration
For production agents, lock to a specific toolkit using theprofile URL parameter:
Reference Implementation
mastra-reference-implementation-civic
Complete implementation with Fastify chat UI and deployment guide
Next Steps
Agent Deployment
Production deployment guide: profile locking, URL params, authentication
Guardrails
Constrain what tools your agent can call
Audit Trail
Query what your agent did via Civic Chat
Get Credentials
Token generation and URL parameter reference

