Motia mcp server
This pull request adds a comprehensive error handling and introspection system for the Motia MCP Server, along with utilities and middleware for validating requests and origins. The changes introduce structured error classes, core and origin validation middleware, new MCP service modules for tools and resources, and helper functions for building JSON-RPC responses. These improvements enhance the reliability, security, and introspectability of the Motia API.
Testing state in MCP Inspector
Error Handling and Middleware
- Introduced a base error class
BaseErrorfor consistent API error handling, including status codes, error codes, and metadata, with atoJSONmethod for API responses. - Added specific MCP error classes (e.g.,
MCPOriginError,MCPMethodNotFoundError, etc.) for granular error reporting in MCP operations. - Implemented
coreMiddlewareto catch and log errors, handle validation and custom errors, and return standardized error responses. - Added
originValidationMiddlewareto enforce MCP specification by validating theOriginheader and preventing DNS rebinding attacks.
Motia Introspection and MCP Services
- Created
motia-introspection.ts, a singleton service for introspecting Motia internals (steps, flows, topics, endpoints) for use by MCP tools and resources. - Added MCP service exports (
tools,resources,prompts,motia-introspection) to centralize domain-driven MCP logic.
MCP Tools and Resources
- Defined a set of MCP tools (e.g.,
trigger_workflow,call_api,get_execution_logs, etc.) with input schemas for workflow automation and state management. - Implemented resource listing and reading functions, allowing MCP clients to discover and retrieve Motia steps, flows, topics, endpoints, and documentation (including a Markdown quick start guide).
JSON-RPC Response Utilities
- Added helper functions to build standardized MCP JSON-RPC success and error responses, including standard error codes and common error responses.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| motia-docs | Preview | Comment | Oct 15, 2025 8:45am | |
| motia-ui | Preview | Comment | Oct 15, 2025 8:45am |
⚠️ This PR is quite large (>1000 lines). Consider splitting it into smaller PRs for easier review.
E2E Test Results ✅
All tests have completed. Tests passed.
Matrix: 2 OS (Ubuntu, macOS) × 2 Templates (Node.js, Python) = 4 jobs
This comment is automatically posted by the PR E2E Results workflow.