π Agenterra: Model Context Protocol Generator
Generate production-ready MCP (Model Context Protocol) servers and clients from OpenAPI specs with minimal configuration.
Agenterra transforms your OpenAPI specifications into fully-functional MCP servers and clients with type-safe Rust code, ready for integration with AI tools and workflows. Perfect for:
- AI/ML Engineers π€ - Quickly expose APIs for LLM tool use
- API Developers π οΈ - Generate production-ready MCP servers from existing OpenAPI specs
- FinTech & Data Teams π - Build compliant financial data APIs with built-in validation
- Startups & Enterprises π - Accelerate development of AI-powered applications
β¨ Features
- β‘ Blazing Fast - Built with Rust for maximum performance and safety
- π OpenAPI 3.0+ Support - Seamless integration with existing API specifications
- π¦ Type-Safe Rust - Generate idiomatic, production-ready Rust code
- π¨ Template-Based - Customize every aspect with Tera templates
- π Built-in Validation - Automatic OpenAPI schema validation
- π Production Ready - Includes logging, error handling, and configuration out of the box
- π MCP Protocol Support - Full compatibility with Model Context Protocol
- πΎ SQLite Resource Caching - Built-in resource caching with connection pooling for MCP clients
- π‘οΈ Client Permission Management - Interactive tool permission prompting with persistent preferences
- π¦ Binary Distribution - Easy installation and deployment
- π Embedded Templates - Templates included in binary for
cargo installsupport
π Security
Agenterra generates code with security features built-in. Every generated server and client includes comprehensive protection against modern attack vectors.
Key Security Features:
- Input Validation: Protection against SQL injection, command injection, and prompt injection
- Unicode Security: Detection of zero-width characters and emoji-based attacks
- Transport Security: Secure SSE mode with URL validation
- Resource Protection: Size limits and rate limiting to prevent DoS
See Security Features for complete details.
π Quick Start
Prerequisites
Method 1: Build & Run from Source
# Clone the repository
# Generate MCP server from a local file without install:
# Generate MCP server from a remote URL without install:
# Generate MCP client without install:
# Or install the CLI
# Generate your MCP server from a local file
# Generate MCP server from a remote URL
# Generate MCP client
Note: After the single-crate refactor, you can now install directly from the project root with
cargo install --path .
Method 2: Install from Git
# Install latest version
# Install specific version. Example: v0.1.0
Method 3: From Pre-built Binary (Coming soon)
- Download the latest release for your platform from Releases
- Make it executable and run:
# Generate your MCP server from a local file # Generate MCP server from a remote URL # Generate MCP client
π Integrating with MCP Clients
VS Code Integration
Add this to your VS Code settings (File > Preferences > Settings > Open Settings JSON):
Cursor Integration
Add this to your Cursor settings (File > Preferences > Settings > Extensions > MCP):
π΅οΈββοΈ Testing with MCP Inspector
Test your MCP server with the MCP Inspector:
# Test STDIO mode (default)
# Test SSE mode
# Or install globally
Testing SSE Endpoints
When running in SSE mode, the server exposes HTTP endpoints:
# Start server in SSE mode
# Test SSE endpoint with curl
# Send MCP messages via POST
β‘ Best Practices
Agenterra is designed to scaffold a well-structured MCP servers from OpenAPI specs. This is a great starting point, not necessarily a Best Practice. Wrapping an OpenAPI spec under an MCP facade is convenient, but not always the βproperβ way to build MCPs. For robust, agent-friendly tools, consider how your server can best expose business logic, aggregate data, and provide clear, useful tool contracts.
Considerations:
- Treat the generated code as a foundation to extend and customize.
- Don't assume a 1:1 mapping of OpenAPI endpoints to MCP tools is ideal; you may want to aggregate multiple API calls into a single tool, or refactor handlers for advanced logic.
- Use the scaffold to rapidly stub out endpoints, then iterate and enhance as needed.
π€ Why Agenterra?
Postman now offers robust support for the Model Context Protocol (MCP), including:
- MCP client and server features
- Code generation
- A catalog of hosted, discoverable MCP endpoints
- Visual agent-building and cloud collaboration
When should you use Agenterra?
- Offline, air-gapped, or regulated environments where cloud-based tools aren't an option
- Rust-first, codegen-centric workflows: Generate type-safe, production-grade Rust MCP servers from OpenAPI specs, ready for CI/CD and self-hosting
- Full template control: Tweak every line of generated code, use custom templates, and integrate with your own infra
- CLI-first automation: Perfect for embedding in build scripts and automated workflows
When should you use Postman?
- Visual design, rapid prototyping, and cloud collaboration
- Building, testing, and deploying MCP agents with a GUI
- Discovering and consuming public MCP endpoints
Summary:
- Use Postman for visual, collaborative, and cloud-first agent development
- Use Agenterra for local, reproducible, code-first MCP server generation with maximum control and zero cloud dependencies
ποΈ Architecture
Agenterra is built for extensibility, automation, and code quality. Here's how the core pieces fit together:
Core Modules:
openapi: Loads and validates OpenAPI specs (YAML/JSON, local or URL)generator: Orchestrates code generation from the parsed OpenAPI modeltemplate: Handles Tera-based templates for idiomatic Rust codecli: Command-line interface for scaffolding, configuration, and workflow
Code Generation Flow:
OpenAPI Spec (local file or URL)
β
βΌ
[openapi module]
β
βΌ
[generator module]
β
βΌ
[template module]
β
βΌ
Generated Rust MCP Server (Axum, etc.)
- The generated servers support both STDIO and SSE (Server-Sent Events) transports for MCP protocol
- All code is idiomatic Rust, ready for further customization and production deployment
π Transport Configuration
Generated servers and clients support multiple transport modes:
Server Transport Options
# STDIO mode (default) - for direct process communication
# SSE mode - for HTTP-based communication
# With custom keep-alive interval
# Configuration via command-line arguments only
Client Transport Options
# STDIO mode (default) - connects to server process
# SSE mode - connects to HTTP endpoint
πΎ Resource Caching
Generated MCP clients include a sophisticated SQLite-powered resource caching system:
Features:
- Connection Pooling - r2d2 connection pool for concurrent access
- TTL Support - Configurable time-to-live for cache entries
- Analytics - Built-in cache hit/miss tracking and performance metrics
- ACID Transactions - Database integrity with rollback support
- Auto-cleanup - Configurable expired resource cleanup
Configuration Options:
// Resource cache configuration
let cache_config = CacheConfig ;
// Database connection configuration (separate from cache config)
let db_config = DatabaseConfig ;
π€ Contributing
We welcome contributions from the community! To keep Agenterra high-quality and maintainable, please follow these guidelines:
- Fork & Clone: Fork the repo and clone your fork locally.
- Branch Naming: Use the convention
<type>/issue-<number>/<description>(e.g.,docs/issue-57/update-readme). - Pull Requests:
- All PRs require review.
- All tests must pass (
cargo testand integration tests). - Code coverage must not decrease.
- Update documentation for any user-facing or API changes.
- Testing:
- Add or update unit and integration tests for all new features or bugfixes.
- Run:
cargo test --test e2e_mcp_test
- Docs:
- Update relevant docs and add examples for new features.
- Document any new patterns or conventions.
- CI/CD:
- Ensure your branch passes all checks before requesting review.
For more details, see CONTRIBUTING.md if available.
π οΈ Developer Workflow
Here's how to work productively with Agenterra as a contributor or advanced user:
π§ͺ Running Tests
- Unit & Integration Tests:
- Run all tests:
cargo test - Run integration tests (all templates with OpenAPI specs):
- Run all tests:
- Test Location: See
tests/e2e_mcp_test.rsfor integration coverage. - Test-First Principle: Add failing tests before implementing new features or bugfixes.
ποΈ Building
- Standard build:
π§© Custom Templates
- See
docs/TEMPLATES.mdfor template development - Add templates under
templates/directory
π Examples & Configuration
Basic Example: Petstore API
# Download the Petstore OpenAPI spec
# Generate the MCP server
# Generate the MCP client
# Build and run the server
Configuration Options
Agenterra is configured through command-line arguments. By default, projects are created in the current directory (like cargo new):
# Generate MCP server (creates ./my_server/)
# Generate MCP client (creates ./my_client/)
# Specify a parent directory with --output-dir
# Creates: ~/projects/my_server/
Environment Variables:
AGENTERRA_OUTPUT_DIR- Default parent directory for generated projectsAGENTERRA_TEMPLATE_DIR- Custom template directory location
Templates
Agenterra uses Tera templates for code generation. Templates are embedded in the binary for easy distribution and can be managed using the built-in template commands.
Built-in Server Templates:
rust- Rust MCP server using Axum web framework
Built-in Client Templates:
rust- Rust MCP client with REPL interface and SQLite resource caching
Managing Templates:
# List all available embedded templates
# Show detailed information about a specific template
# Export all templates to a directory
# Export a single template
Custom Templates:
- Use exported templates as a starting point for customization
- Specify custom template directory with
--template-dirwhen scaffolding - Create templates under
templates/mcp/server/ortemplates/mcp/client/ - Details: See
docs/TEMPLATES.md
Project Structure: Each generated project includes a detailed README.md with template-specific project structure documentation, usage examples, and configuration options.
π License
MIT License - see LICENSE for details.
π Related Projects
- MCP Protocol - Model Context Protocol specification
- RMCP - Rust MCP implementation
- Axum - Web framework for Rust
- Tera - Template engine for Rust