beaukuhn_automcp

beaukuhn_automcp

by beaukuhn
AutoMCP automatically generates MCP-compatible server and client code from YAML service definitions.

AutoMCP Code Generator for Model Context Protocol

AutoMCP Logo

AutoMCP is a powerful code generator designed to automatically create server and client code based on YAML service definitions for the Model Context Protocol (MCP). This tool simplifies the process of building MCP-compatible services and client libraries, making it ideal for developers working on agentic workflows.

Overview

AutoMCP is a library that generates MCP-compatible server and client code from YAML service definitions. It organizes code by service, creates handler stubs for implementing tool functionality, and streamlines the development process. This project is still a work in progress, with plans for future enhancements and integrations.

Features

  • Server Code Generation: Automatically generates MCP-compatible server code.
  • Client Library Creation: Produces client libraries for easy service consumption.
  • Handler Stubs: Creates stubs for implementing tool functionality.
  • Service Organization: Organizes code into dedicated directories by service.

Getting Started

Prerequisites

  • Node.js 18 or higher
  • npm or yarn

Installation

  1. Clone the repository:
    bash git clone https://github.com/beaukuhn/automcp.git
  2. Install dependencies:
    bash 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

Check out 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

.
├── 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
  • Custom typing to prevent schema drift
  • Integration with existing MCP solutions
  • Enhanced composition mechanisms for complex tool chains

License

This project is licensed under the MIT License.

About

AutoMCP is a library for autogenerating MCP server and client code based on a specified YAML schema. It is designed to simplify the development of MCP-compatible services and client libraries.

Resources

Activity


No releases or packages have been published yet.

Features & Capabilities

Categories
mcp_server model_context_protocol typescript nodejs code_generation yaml api_integration

Implementation Details

Stats

0 Views
0 Favorites
1 GitHub Stars

Repository Info

beaukuhn Organization

Similar Servers

continuedev_continue by continuedev
0
0
0