Overview
The Model Context Protocol (MCP) is a standardized protocol for connecting AI agents to external tools and data sources. Pricing Intelligence implements MCP to enable Harvey (the AI agent) to invoke pricing analysis tools without tight coupling.Pricing Intelligence follows the MCP 2025-06-18 specification for both server and client implementations.
Why MCP?
Traditional AI agent architectures face several challenges:Tight Coupling
Agent code directly calls backend APIs, making changes brittle
Secret Sharing
Agents need API keys for every service they call
No Standardization
Every integration uses different protocols and formats
Poor Observability
Difficult to trace what tools are being invoked and why
- Standardizing tool invocation with JSON-RPC
- Abstracting backend services behind a protocol layer
- Centralizing authentication at the server level
- Enabling introspection (agents can discover available tools)
MCP Architecture
Pricing Intelligence uses MCP to connect Harvey (client) to the MCP Server (server):Key Design Decision
Client-Mediated Authentication
The MCP server does not hold API keys. Harvey (the client) provides credentials when launching the server. This aligns with MCP’s security model where clients control access.From the Harvey API README:
“No LLM or upstream API keys are required in the MCP server when used this way, aligning with MCP’s client‑mediated access model.”
MCP Components
MCP defines three types of resources that servers can expose:1. Tools
Tools are executable functions that agents can invoke. Pricing Intelligence exposes five tools:iPricing
Fetches or returns Pricing2Yaml documents
summary
Provides catalog-level statistics
subscriptions
Enumerates valid configurations
optimal
Finds best configuration by objective
validate
Validates pricing model consistency
- Has a name (e.g.,
"optimal") - Accepts structured arguments (JSON schema)
- Returns structured results (JSON content blocks)
- Can raise errors (JSON-RPC error responses)
2. Resources
Resources are static data that agents can read. Pricing Intelligence exposes one resource:resource://pricing/specification
The Pricing2Yaml specification markdown document. Harvey reads this when users ask about schema syntax or validation rules.URI:
resource://pricing/specificationContent: Full Pricing2Yaml syntax specification3. Prompts (Not Used)
MCP also supports prompts (reusable prompt templates), but Pricing Intelligence does not currently expose any. Harvey maintains its own planning and answer prompts internally.Tool Invocation Flow
Here’s how Harvey invokes an MCP tool:MCP Server Processes
The MCP server:
- Validates the arguments
- Calls the internal workflow (
container.workflow.run_optimal(...)) - The workflow fetches YAML (via A-MINT), invokes the Analysis API, and receives CSP results
Why stdio? MCP supports multiple transports (HTTP, WebSocket, stdio). Pricing Intelligence uses stdio (standard input/output) for local server communication. Harvey spawns the MCP server as a subprocess and communicates via JSON-RPC over stdin/stdout.
MCP Server Implementation
The MCP server is implemented in Python using the official MCP SDK:FastMCP SDK
Pricing Intelligence uses thefastmcp library, which provides:
- Decorator-based tool registration:
@mcp.tool() - Automatic JSON-RPC handling: Converts Python functions to MCP tools
- Type validation: Uses Python type hints for argument validation
- Multiple transports: Supports stdio, HTTP, WebSocket
- Logging and observability: Structured logging for all tool invocations
Tool Signatures
Common Parameters
All tools accept:URL of the SaaS pricing page (e.g.,
"https://buffer.com/pricing"). The server will fetch and parse the Pricing2Yaml model.Direct Pricing2Yaml content as a string. Use this if you have the YAML already (e.g., from a file upload).
If
true, bypass caches and fetch fresh data. Useful for development or when you know a pricing page has changed.Tool-Specific Parameters
optimal
optimal
Filter criteria (see CSP Analysis for schema)
Optimization objective:
"minimize" or "maximize"CSP solver:
"minizinc" or "choco"subscriptions
subscriptions
validate
validate
CSP solver:
"minizinc" or "choco"summary
summary
No additional parameters (only
pricing_url, pricing_yaml, refresh)iPricing
iPricing
No additional parameters (only
pricing_url, pricing_yaml, refresh)Workflow Orchestration
Internally, the MCP server delegates to a workflow layer that orchestrates backend services:Caching Strategy
The MCP server implements caching to reduce latency and API costs:In-Memory Cache
Default: Simple Python dict for storing transformed YAML. Fast but lost on restart.
Redis Cache
Optional: Persistent cache shared across instances. Enable via
CACHE_BACKEND=redis.pricing:{url}→ Full Pricing2Yaml contentsummary:{url}→ Summary statisticsvalidation:{url}:{solver}→ Validation results
- Pricing YAML: 24 hours (pricing pages don’t change often)
- Summaries: 24 hours
- Validation: 24 hours
- Analysis results: No caching (user-specific filters)
Use
refresh=true in tool calls to bypass cache and force fresh data fetching.Error Handling
MCP uses JSON-RPC error responses. The server translates Python exceptions:-32600: Invalid Request-32601: Method not found (unknown tool name)-32602: Invalid params (bad arguments)-32603: Internal error (server crash)-32000to-32099: Custom application errors
Configuration
MCP server behavior is controlled via environment variables:Server name reported in
initialize responseTransport protocol:
"stdio", "http", or "websocket"Bind address for HTTP/WebSocket transports
Port for HTTP/WebSocket transports
Base URL for A-MINT transformation API
Base URL for Analysis API
Cache implementation:
"memory" or "redis"Redis connection string (if
CACHE_BACKEND=redis)Logging verbosity:
"DEBUG", "INFO", "WARNING", "ERROR"Observability
The MCP server emits structured logs for all operations:- Performance monitoring: Track tool execution times
- Usage analytics: See which tools are most popular
- Debugging: Trace failures back to specific invocations
- Auditing: Record all pricing analysis requests
Testing MCP Tools
You can test MCP tools directly using themcp CLI:
MCP vs Direct API Calls
Why use MCP instead of Harvey calling the Analysis API directly?Abstraction
Harvey doesn’t need to know about A-MINT, Analysis API, or CSP solvers. It just calls MCP tools.
Introspection
MCP provides
tools/list to discover available tools dynamically. Future agents can adapt without code changes.Security
API keys for A-MINT and Analysis API are hidden from Harvey. Only the MCP server needs them.
Testability
You can test MCP tools independently of Harvey. Swap implementations without changing the agent.
Standardization
MCP is an open protocol. Future clients (other than Harvey) can use the same tools.
Observability
Centralized logging at the MCP layer provides a single audit trail.
Future Enhancements
Potential MCP features for Pricing Intelligence:Further Reading
MCP Specification
Official MCP protocol documentation
FastMCP SDK
Python MCP server library
MCP Tools Reference
Pricing Intelligence MCP tools
Harvey Agent
How Harvey uses MCP