Navigation
AutoMCP: Automates YAML-Driven Code Generation - MCP Implementation

AutoMCP: Automates YAML-Driven Code Generation

AutoMCP automates MCP server/client code generation from YAML schemas—fast, precise, and developer-friendly, eliminating manual coding headaches.

Developer Tools
4.2(194 reviews)
291 saves
135 comments

Ranked in the top 4% of all AI tools in its category

About AutoMCP

What is AutoMCP: Automates YAML-Driven Code Generation?

AutoMCP is a code generation tool tailored for the Model Context Protocol (MCP), designed to automate the creation of server and client code from YAML-based service definitions. By parsing structured YAML files, it generates production-ready components while abstracting away boilerplate logic. Currently under active development, the project prioritizes flexibility and scalability for future integrations with package managers like npm and PyPI.

How to Use AutoMCP: Automates YAML-Driven Code Generation?

Adopting AutoMCP follows a straightforward workflow:

  1. Setup: Install Node.js 18+ and clone the repository. Run npm install to prepare dependencies.
  2. Define Services: Create YAML files in services/[service-name]/ specifying service metadata and tool interfaces. Each tool requires parameters, return types, and descriptions.
  3. Generate Code: Execute ./bin/automcp.sh generate to produce server, client, and handler stubs. Generated files are organized into dedicated directories for clarity.
  4. Implement Logic: Extend handler stubs in src/custom/[service-name]/ to embed business-specific functionality.
  5. Deploy Clients: Import generated clients and invoke tools via asynchronous methods, ensuring proper lifecycle management with connect/disconnect handlers.

AutoMCP Features

Key Features of AutoMCP: Automates YAML-Driven Code Generation?

AutoMCP's architecture emphasizes developer efficiency through:

  • Protocol Compliance: Automatically enforces MCP standards for server and client interoperability
  • Modular Output: Separates generated code into service-specific directories for maintainability
  • Standalone Handler Framework: Provides extensible TypeScript stubs to decouple business logic from infrastructure
  • Documentation-Driven Design: YAML definitions serve as both configuration and technical documentation

Use Cases of AutoMCP: Automates YAML-Driven Code Generation?

Teams benefit most from AutoMCP in scenarios requiring:

  • Rapid API Prototyping: Quickly test service interfaces without manual scaffolding
  • Service Contract Management: Maintain version-controlled definitions for multi-team API contracts
  • Consistent Tooling: Ensure standardized implementations across microservices architectures
  • Language-Agnostic Pipelines: Lay groundwork for future multi-language support in cross-platform toolchains

AutoMCP FAQ

FAQ from AutoMCP: Automates YAML-Driven Code Generation?

Q: Does AutoMCP support other languages besides TypeScript?
Current implementation focuses on TypeScript, but planned enhancements include Python and Go support through template expansion.

Q: Can I customize the generated code structure?
While the directory layout is fixed for consistency, handler implementations remain fully customizable through the src/custom extension pattern.

Q: How is code generation validated?
Built-in test scripts (test-service.sh) execute end-to-end checks against defined service contracts to ensure correctness.

Q: Can AutoMCP integrate with existing MCP systems?
Yes, the tool's output adheres to MCP standards, enabling seamless integration with frameworks like MCP Agent for agent-based workflows.

Q: What performance overhead does code generation introduce?
The generation process is lightweight and executed during development phases, ensuring no runtime impact on deployed services.

Content

AutoMCP

AutoMCP Logo

AutoMCP is a code generator for the Model Context Protocol that automatically creates server and client code based on YAML service definitions.

This is a work in progress. The repo contains artifacts that will be removed when finalized for packaging for npm, pypl, etc.

Please refer to MCP Agent to have an idea of how you could use this in agentic workflows.

Features

  • Generates MCP-compatible server code
  • Generates client libraries for easy service consumption
  • Creates handler stubs for implementing tool functionality
  • Organizes code by service in dedicated directories

Getting Started

Prerequisites

  • Node.js 18 or higher
  • npm or yarn

Installation

  1. Clone this repository

  2. Install dependencies:

    npm install

Usage

Defining a Service

Create a YAML file in the services/[service-name]/ directory with the following structure:

service:
  name: ServiceName
  version: 1.0.0
  description: Description of your service

tools:
  - name: toolName
    description: Description of what the tool does
    parameters:
      - name: paramName
        type: string
        description: Description of the parameter
    returns:
      type: string
      description: Description of what the tool returns

Generating Code

Run the generator script:

./bin/automcp.sh generate

This will:

  1. Create server code in generated/[service-name]/[service-name]_server.ts
  2. Create client code in generated/[service-name]/[service-name]_client.ts
  3. Create handler stubs in src/custom/[service-name]/[tool-name]Handlers.ts

Implementing Handlers

Edit the generated handler files in src/custom/[service-name]/ to implement your tool functionality.

Using the Generated Clients

import { ServiceNameClient } from "./generated/service-name/service_name_client.js";

async function main() {
  const client = new ServiceNameClient();

  try {
    await client.connect();

    // Call a tool
    const result = await client.toolName({ paramName: "value" });
    console.log(result);
  } finally {
    await client.disconnect();
  }
}

main().catch(console.error);

Example

See the examples/client_example.ts file for a complete example of using the generated clients.

Testing

Use the test script to verify the functionality of your services:

./bin/test-service.sh [service-name]

Temporary Directory Structure (will be improved for packaging)

.
├── bin/                    # Scripts
├── examples/               # Example usage
├── generated/              # Generated code
│   ├── service-name/       # Service-specific generated code
│   │   ├── service_name_server.ts
│   │   └── service_name_client.ts
├── services/               # Service definitions
│   └── service-name/       # Service-specific YAML files
├── src/                    # Source code
│   ├── custom/             # Custom handler implementations
│   │   └── service-name/   # Service-specific handlers
│   │       └── toolHandlers.ts
│   └── generator.ts        # Code generator
└── templates/              # Code templates
    ├── client.ts.ejs       # Client template
    └── server.ts.ejs       # Server template

Future Plans

  • Support for multiple programming languages
  • Add custom typing so schemas do not drift from generated code
  • Integration with existing MCP solutions
  • Implement with prompts and resource mechanisms
  • Enhanced composition mechanisms for complex tool chains

License

MIT

Related MCP Servers & Clients