Trace MCP is a static analysis engine that detects schema mismatches between data producers (APIs, backends) and consumers (frontends, clients) across multiple languages and frameworks before runtime.
Core Capabilities:
Schema Extraction: Extract producer schemas from MCP tools (Zod), OpenAPI/Swagger specs, TypeScript interfaces, tRPC routers, REST endpoints (Express, Fastify, FastAPI, Flask, Chi, Gin), GraphQL SDL/Apollo resolvers, Go structs/interfaces, and gRPC/Protobuf definitions. Extract from entire directories with glob patterns or single files.
Consumer Usage Tracing: Analyze how client code consumes schemas by tracking property access patterns,
callTool()invocations, HTTP client calls (fetch, axios, requests, httpx, aiohttp), and GraphQL client hooks (Apollo Client).Mismatch Detection: Compare producer schemas against consumer expectations with a full analysis pipeline. Generate detailed reports in JSON, Markdown, or summary formats with bidirectional validation (producer→consumer, consumer→producer, or both) and optional strict mode.
Code Generation: Scaffold type-safe consumer code (TypeScript functions, React hooks, Zustand actions) from producer schemas, or generate producer stubs from consumer usage patterns. Automatically includes error handling and TypeScript types.
Project Management: Initialize trace projects with persistent configuration, enable watch mode for continuous validation with auto-revalidation on file changes, monitor project status (config, cache, validation results), and add cross-reference comments to document validated contracts.
Supported Languages & Frameworks: TypeScript, Python, Go, and Protobuf with MCP, OpenAPI, tRPC, gRPC, Express, Fastify, FastAPI, Flask, Chi, Gin, GraphQL (SDL/Apollo), and various HTTP client libraries.
Reliability: 1047 tests across 16 suites with an extensible pattern matcher framework supporting call, decorator, property, export, and chain patterns with cross-file import resolution.
Planned adapter support for GraphQL schema validation and mismatch detection between producers and consumers.
Supports JavaScript code analysis for tracing MCP tool usage and generating scaffolded consumer code from producer schemas.
Generates formatted analysis reports showing schema mismatches, tool statistics, and validation results in markdown format.
Provides partial support for Python language analysis in producer and consumer schema extraction and validation workflows.
Generates React hooks from MCP tool schemas, enabling type-safe integration of producer schemas into React applications.
Provides partial support for Rust language analysis in producer and consumer schema extraction and validation workflows.
Analyzes TypeScript code to extract MCP tool definitions, trace usage patterns, detect schema mismatches between producers and consumers, and generate scaffolded code with type definitions.
Extracts and analyzes Zod schema definitions from MCP server tool declarations to validate data contracts between producers and consumers.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Trace MCPcompare my backend and frontend for mismatches"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mnehmos.trace.mcp
Static analysis engine for detecting schema mismatches between data producers and consumers.
What It Does
Trace MCP finds mismatches between:
Backend API responses and frontend expectations
MCP tool outputs and client code that uses them
Service A's events and Service B's handlers
REST endpoints and HTTP client calls
GraphQL schemas and Apollo Client hooks
Features
Core Capabilities
Feature | Description |
Schema Extraction | Extract schemas from MCP tools, OpenAPI, TypeScript, tRPC, REST endpoints, GraphQL |
Usage Tracing | Track how client code consumes schemas via property access patterns |
Mismatch Detection | Compare producer schemas against consumer expectations |
Code Generation | Scaffold consumer code from producer schemas (and vice versa) |
Watch Mode | Continuous validation on file changes |
Phase 2 Capabilities
Feature | Description |
Pattern Matcher | Extensible pattern detection supporting call, decorator, property, export, and chain patterns |
Import Resolution | Cross-file type resolution with import graph building and circular dependency handling |
REST Detection | Express and Fastify endpoint extraction with validation middleware support |
HTTP Client Tracing | fetch() and axios call detection with URL extraction and type inference |
GraphQL Support | SDL schema parsing, Apollo Server resolvers, and Apollo Client hook tracing |
Phase 3 Capabilities
Feature | Description |
Python AST Parser | FastAPI, Flask, and MCP tool extraction with Pydantic model support |
Go Language Parser | Struct/interface extraction with Chi, Gin, and stdlib HTTP handler detection |
gRPC/Protobuf Support | Proto3 parsing with message, enum, service, and streaming RPC extraction |
Python HTTP Clients | requests, httpx, and aiohttp library detection with response property tracing |
Test Coverage
1047 tests passing across 16 test suites:
Test Suite | Tests |
Pattern Matcher | 85 |
REST Detection | 87 |
HTTP Client Tracing | 90 |
GraphQL Support | 109 |
Import Resolution | 56 |
Core (adapters, OpenAPI, tRPC) | 234 |
Python AST | 121 |
gRPC/Protobuf | 124 |
Go Parser | 106 |
Python HTTP Clients | 35 |
Installation
Configuration
Add to your MCP client configuration (e.g., claude_desktop_config.json or Roo-Code settings):
Supported Formats
Trace MCP supports schema extraction and comparison across multiple specification formats through a pluggable adapter registry.
Summary of Supported Frameworks
Category | Frameworks |
API Specs | OpenAPI 3.0+, Swagger |
RPC | MCP (Zod), tRPC, gRPC/Protobuf |
REST Servers | Express, Fastify, FastAPI, Flask, Chi, Gin, Go stdlib |
HTTP Clients | fetch(), axios, requests, httpx, aiohttp |
GraphQL | SDL schemas, Apollo Server, Apollo Client |
Type Systems | TypeScript interfaces, Zod schemas, Pydantic models, Go structs |
Supported Languages
Language | Producer Detection | Consumer Tracing |
TypeScript | MCP tools, tRPC, Express, Fastify, GraphQL resolvers | callTool(), fetch, axios, Apollo Client |
Python | FastAPI, Flask, MCP tools, Pydantic models | requests, httpx, aiohttp |
Go | Chi, Gin, stdlib handlers, structs, interfaces | — |
Protobuf | Messages, enums, services, streaming RPCs | — |
MCP Server Schemas (Zod)
Extract MCP tool definitions from server source code using Zod schemas.
Schema ID Format: endpoint:GET:/tools/get_character@./server.ts
OpenAPI / Swagger Specifications
Extract schemas from OpenAPI 3.0+ specifications, supporting endpoints, request bodies, responses, and component schemas.
Schema ID Format: endpoint:GET:/characters/{id}@./api.yaml
Usage Example:
TypeScript Interfaces & Types
Extract exported interfaces, type aliases, and enums from TypeScript source files. Supports utility types including Pick, Omit, Partial, Required, and Record.
Schema ID Format: interface:Character@./types.ts
Supported Utility Types:
Pick<T, K>- Select properties from interfaceOmit<T, K>- Exclude properties from interfacePartial<T>- Make all properties optionalRequired<T>- Make all properties requiredRecord<K, T>- Object with specific keys and value type
Usage Example:
tRPC Routers
Extract procedure schemas from tRPC routers, including input/output types, query, mutation, and subscription handlers. Handles nested routers and middleware.
Schema ID Format: trpc:users.getById@./router.ts
Detected Elements:
Router definitions (
router({ ... }))Nested routers (
users: router({ ... }))Procedures (
.query(),.mutation(),.subscription())Input schemas (
.input(zod_schema))Output schemas (
.output(zod_schema))
Usage Example:
REST Endpoints (Express & Fastify)
Extract endpoint schemas from Express and Fastify applications, including route parameters, request bodies, response types, and validation middleware.
Express
Schema ID Format: rest:GET:/users/:id@./app.ts
Fastify
Schema ID Format: rest:POST:/users@./server.ts
Detected Elements:
HTTP methods: GET, POST, PUT, PATCH, DELETE
Path parameters (
:id,:userId)Request body schemas (Zod, Joi, celebrate, JSON Schema)
Response type inference
Router prefixes and mounting
Usage Example:
HTTP Clients (fetch & axios)
Trace HTTP client calls to detect consumer expectations for API responses.
fetch() API
Detected Elements:
URL extraction (static strings, template literals, variables)
HTTP method detection
Type assertions and generics
Property access patterns on response data
axios
Schema ID Format: http-client:GET:/api/users@./client.ts
Detected Elements:
axios methods:
.get(),.post(),.put(),.patch(),.delete()Generic type parameters (
axios.get<User>)Instance creation with
axios.create()Base URL resolution
Response data property access
Usage Example:
GraphQL (SDL & Apollo)
Extract schemas from GraphQL SDL files and trace Apollo Server resolvers and Apollo Client hooks.
SDL Schema Files
Schema ID Format: graphql:Query.user@./schema.graphql
Apollo Server Resolvers
Schema ID Format: graphql-resolver:Query.user@./resolvers.ts
Apollo Client Hooks
Schema ID Format: graphql-client:GetUser@./UserProfile.tsx
Detected Elements:
SDL types: scalar, object, input, enum, interface, union
Query and Mutation definitions
Field arguments and return types
Apollo Client hooks:
useQuery,useMutation,useLazyQuery,useSubscriptionOperation names and variables
Selected fields in queries
Usage Example:
Python (FastAPI, Flask, MCP Tools)
Extract endpoint schemas from Python web frameworks and MCP tool definitions with full Pydantic model support.
FastAPI
Schema ID Format: python:GET:/characters/{character_id}@./main.py
Flask
Schema ID Format: python:GET:/api/users/<user_id>@./app.py
MCP Tools (Python)
Schema ID Format: python-mcp:get_character@./tools.py
Pydantic Models
Detected Elements:
Decorators:
@app.get(),@app.post(),@router.*,@app.route(),@blueprint.route()MCP decorators:
@mcp.tool(),@server.tool()Pydantic
BaseModelclasses with field extractionType annotations:
Optional,Union,List,Dict,LiteralEnum types
Usage Example:
Go Language (Chi, Gin, stdlib)
Extract struct definitions, interfaces, and HTTP endpoint schemas from Go source files.
Structs with JSON Tags
Schema ID Format: go-struct:Character@./models/character.go
Interfaces
Schema ID Format: go-interface:CharacterService@./services/character.go
stdlib HTTP Handlers
Schema ID Format: go-http:GET:/health@./main.go
Chi Router
Schema ID Format: go-http:GET:/api/characters/{id}@./main.go
Gin Framework
Schema ID Format: go-http:GET:/api/characters/:id@./main.go
Detected Elements:
Struct definitions with JSON tags
Embedded structs
Interface definitions
http.HandleFunc()patternsChi router:
r.Get(),r.Post(),r.Route(),{param}syntaxGin framework:
r.GET(),r.POST(),r.Group(),:paramsyntax
Usage Example:
gRPC / Protobuf
Parse Protocol Buffer definitions (proto3) to extract message types, enums, services, and RPC methods.
Basic Messages
Schema ID Format: proto-message:character.Character@./character.proto
Enums
Schema ID Format: proto-enum:character.CharacterClass@./character.proto
Oneof and Map Fields
Schema ID Format: proto-message:character.Equipment@./equipment.proto
Services and RPCs
Schema ID Format: proto-service:character.CharacterService@./character.proto
RPC Format: proto-rpc:CharacterService.GetCharacter@./character.proto
Well-Known Types
Detected Elements:
Messages with all field types (scalar, message, enum, repeated)
Enums with numeric values
oneoffield groupsmap<K, V>fieldsNested message definitions
Service definitions with all streaming modes:
Unary:
rpc Method(Request) returns (Response)Server streaming:
rpc Method(Request) returns (stream Response)Client streaming:
rpc Method(stream Request) returns (Response)Bidirectional:
rpc Method(stream Request) returns (stream Response)
Well-known types:
Timestamp,Duration,Any,Struct
Usage Example:
Python HTTP Clients (requests, httpx, aiohttp)
Trace HTTP client calls in Python code to detect consumer expectations.
requests Library
Schema ID Format: python-http:GET:/characters@./client.py
httpx Library
Schema ID Format: python-http:GET:/characters@./client.py
aiohttp Library
Schema ID Format: python-http:POST:/characters@./client.py
Detected Elements:
requests.get(),requests.post(), etc.httpx.get(),httpx.post(),AsyncClientmethodsaiohttp.ClientSessionmethodsURL extraction (static strings, f-strings)
HTTP method detection
Response property access (dictionary key access)
Usage Example:
Architecture
Pattern Matcher Framework
The pattern matcher provides an extensible system for detecting code patterns across different frameworks. Located in src/patterns/:
Supported Pattern Types:
Call patterns: Function/method calls (
app.get(),fetch())Decorator patterns: TypeScript/Python decorators (
@Controller())Property patterns: Object property assignments
Export patterns: Module exports (
export const router = ...)Chain patterns: Method chaining (
router.get().post())
Import Resolution
Cross-file type resolution with import graph building. Located in src/languages/import-resolver.ts:
Resolves
import { Type } from "./types"Handles barrel exports (
export * from)Supports path aliases via tsconfig.json
Detects and handles circular dependencies
Caches resolved types for performance
Tools Reference
Trace MCP provides 11 tools organized into three categories:
Core Analysis Tools
Tool | Description |
| Extract MCP tool definitions from server source code |
| Extract schemas from a single file |
| Trace how client code uses MCP tools |
| Trace tool usage in a single file |
| Full pipeline: extract → trace → compare → report |
Code Generation Tools
Tool | Description |
| Generate client code from producer schema |
| Generate server stub from client usage |
| Add cross-reference comments to validated pairs |
Project Management Tools
Tool | Description |
| Initialize a trace project with |
| Watch files for changes and auto-revalidate |
| Get project config, cache state, and validation results |
Tool Details
extract_schemas
Extract MCP tool definitions (ProducerSchemas) from server source code. Scans for server.tool() calls and parses their Zod schemas. Also supports OpenAPI, TypeScript interfaces, tRPC routers, REST endpoints, and GraphQL schemas.
Parameters:
rootDir(required): Root directory of server source codeinclude: Glob patterns to include (default:**/*.ts)exclude: Glob patterns to exclude (default:node_modules,dist)
Example:
extract_file
Extract MCP tool definitions from a single TypeScript file.
Parameters:
filePath(required): Path to a TypeScript file
trace_usage
Trace how client code uses MCP tools. Finds callTool() invocations, HTTP client calls, and GraphQL hooks, tracking which properties are accessed on results.
Parameters:
rootDir(required): Root directory of consumer source codeinclude: Glob patterns to includeexclude: Glob patterns to exclude
trace_file
Trace MCP tool usage in a single TypeScript file.
Parameters:
filePath(required): Path to a TypeScript file
compare
Full analysis pipeline: extract producer schemas, trace consumer usage, and compare them to find mismatches.
Parameters:
producerDir(required): Path to MCP server source directoryconsumerDir(required): Path to consumer/client source directoryformat: Output format (json,markdown,summary)strict: Strict mode - treat missing optional properties as warningsdirection: Data flow direction (producer_to_consumer,consumer_to_producer,bidirectional)
Example Output (Markdown):
scaffold_consumer
Generate consumer code from a producer schema. Creates TypeScript functions, React hooks, or Zustand actions that correctly call MCP tools.
Parameters:
producerDir(required): Path to MCP server source directorytoolName(required): Name of the tool to scaffoldtarget: Output format (typescript,javascript,react-hook,zustand-action)includeErrorHandling: Include try/catch error handling (default: true)includeTypes: Include TypeScript type definitions (default: true)
Example Output:
scaffold_producer
Generate producer schema stub from consumer usage. Creates MCP tool definition based on how client code calls it.
Parameters:
consumerDir(required): Path to consumer source directorytoolName(required): Name of the tool to scaffoldincludeHandler: Include handler stub (default: true)
Example Output:
comment_contract
Add cross-reference comments to validated producer/consumer pairs. Documents the contract relationship in both files.
Parameters:
producerDir(required): Path to MCP server source directoryconsumerDir(required): Path to consumer source directorytoolName(required): Name of the validated tooldryRun: Preview without writing (default: true)style: Comment style (jsdoc,inline,block)
Example Preview:
init_project
Initialize a trace project with .trace-mcp config directory for watch mode and caching.
Parameters:
projectDir(required): Root directory for the trace projectproducerPath(required): Relative path to producer/server codeconsumerPath(required): Relative path to consumer/client codeproducerLanguage: Language (typescript,python,go,rust,json_schema)consumerLanguage: Language (typescript,python,go,rust,json_schema)
Example:
watch
Watch project files for changes and auto-revalidate contracts.
Parameters:
projectDir(required): Root directory with.trace-mcpconfigaction:start,stop,status, orpoll
Actions:
start: Begin watching for file changesstop: Stop watchingstatus: Check current watcher statepoll: Get pending events and last validation result
get_project_status
Get the status of a trace project including config, cache state, and last validation result.
Parameters:
projectDir(required): Root directory with.trace-mcpconfig
Example Output:
Typical Workflow
1. Quick One-Off Analysis
2. Continuous Validation (Watch Mode)
3. Generate Missing Code
4. Extract Multiple Formats
5. Full-Stack GraphQL Validation
Roadmap
Completed
MCP tool schema extraction
Consumer usage tracing
Basic mismatch detection
Code scaffolding (consumer & producer)
Contract comments
Watch mode with auto-revalidation
OpenAPI/Swagger adapter support
TypeScript interface extraction
tRPC router support
Pluggable adapter registry
Pattern Matcher abstraction (Phase 2)
Cross-file import resolution (Phase 2)
REST endpoint detection - Express & Fastify (Phase 2)
HTTP client tracing - fetch & axios (Phase 2)
GraphQL support - SDL, Apollo Server, Apollo Client (Phase 2)
Python language support - FastAPI, Flask, MCP tools, Pydantic (Phase 3)
Go language support - Chi, Gin, stdlib handlers, structs (Phase 3)
gRPC/Protobuf support - proto3, messages, services, streaming (Phase 3)
Python HTTP client tracing - requests, httpx, aiohttp (Phase 3)
Planned
JSON Schema adapter
WebSocket message tracing
OpenTelemetry integration
Rust language support
Java/Kotlin language support
License
MIT