mcp-agentify
v1.0.0
Published
CLI tool to generate Model Context Protocol (MCP) servers from existing REST APIs or Node.js endpoints
Downloads
7
Maintainers
Readme
MCP Agentify
A powerful CLI tool to generate Model Context Protocol (MCP) servers from existing REST APIs or Node.js endpoints.
Features
- 🔍 Smart Analysis: Automatically detects and analyzes REST APIs, Node.js projects, and OpenAPI specifications
- 🚀 Quick Generation: Creates fully functional MCP servers with TypeScript support
- 🛠️ Configurable: Customizable templates and generation options
- 📚 Well Documented: Generates comprehensive documentation and examples
- 🧪 Test Ready: Includes test files and setup
- 🎯 Multi-Language Support: Supports JavaScript, Python, Java, Go, PHP, and Ruby projects
Installation
npm install -g mcp-agentifyOr use directly with npx:
npx mcp-agentify generate --project ./my-apiQuick Start
- Analyze your project:
agentify analyze --project ./my-rest-api- Generate MCP server:
agentify generate --project ./my-rest-api --output ./my-mcp-server- Run the generated server:
cd my-mcp-server
npm install
npm run build
npm startCommands
generate
Generate an MCP server from an existing project:
agentify generate [options]Options:
-p, --project <path>- Path to the project directory (default: ".")-o, --output <path>- Output directory for generated MCP server (default: "./mcp-server")-t, --type <type>- Project type: rest-api, nodejs, openapi (default: "auto")-c, --config <path>- Configuration file path--dry-run- Show what would be generated without creating files
Examples:
# Generate from current directory
agentify generate
# Generate from specific project with custom output
agentify generate --project ./api --output ./my-mcp-server
# Generate from OpenAPI spec
agentify generate --project ./swagger.json --type openapi
# Dry run to see what would be generated
agentify generate --dry-runanalyze
Analyze an existing project to see what endpoints would be detected:
agentify analyze [options]Options:
-p, --project <path>- Path to the project directory (default: ".")-t, --type <type>- Project type: rest-api, nodejs, openapi (default: "auto")--json- Output analysis results as JSON
Examples:
# Analyze current directory
agentify analyze
# Analyze specific project
agentify analyze --project ./my-api
# Get JSON output
agentify analyze --json > analysis.jsoninit
Initialize a configuration file:
agentify init [options]Options:
-o, --output <path>- Configuration file output path (default: "./agentify.config.json")
Configuration
Create a configuration file to customize the generation process:
agentify initThis creates an agentify.config.json file:
{
"serverName": "my-mcp-server",
"description": "Generated MCP server",
"version": "1.0.0",
"outputFormat": "typescript",
"includeTests": true,
"includeDocumentation": true,
"excludeEndpoints": [],
"transformRules": []
}Configuration Options
serverName- Name of the generated MCP serverdescription- Description for the MCP serverversion- Version numberoutputFormat- Output format: "typescript" or "javascript"includeTests- Generate test filesincludeDocumentation- Generate documentationexcludeEndpoints- Array of endpoints to exclude (format: "METHOD:/path")transformRules- Rules to transform endpoint names or parameters
Supported Project Types
Node.js Projects
Automatically detects endpoints in:
- Express.js applications
- Fastify applications
- Koa applications
- NestJS applications
Supported patterns:
app.get('/users', handler);
router.post('/users/:id', handler);
fastify.put('/users/{id}', handler);OpenAPI/Swagger
Supports:
- OpenAPI 3.x specifications
- Swagger 2.x specifications
- JSON and YAML formats
REST API Projects
Detects endpoints in various languages:
Python (Django, Flask, FastAPI):
@app.route('/users', methods=['GET'])
@router.get('/users/{id}')Java (Spring Boot):
@GetMapping("/users")
@RequestMapping(value = "/users", method = RequestMethod.POST)Go (Gin, Echo):
router.GET("/users", handler)
e.POST("/users/:id", handler)PHP (Laravel):
Route::get('/users', 'UserController@index');Ruby (Rails):
get '/users', to: 'users#index'Generated MCP Server
The generated MCP server includes:
File Structure
my-mcp-server/
├── src/
│ ├── index.ts # Main MCP server
│ ├── tools/ # Individual tool implementations
│ └── types/ # TypeScript type definitions
├── tests/ # Test files (if enabled)
├── docs/ # Documentation (if enabled)
├── package.json
├── tsconfig.json
├── .env.example
└── README.mdFeatures
- Full MCP Compliance: Implements the Model Context Protocol specification
- Type Safety: Full TypeScript support with proper type definitions
- Error Handling: Comprehensive error handling and validation
- Environment Configuration: Configurable via environment variables
- Logging: Built-in logging and debugging support
- Testing: Unit tests for all generated tools
- Documentation: Auto-generated API documentation
Usage in MCP Clients
The generated server can be used with any MCP-compatible client:
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["path/to/my-mcp-server/dist/index.js"]
}
}
}Advanced Usage
Custom Templates
Create custom templates for generation:
- Create a
templates/directory in your project - Add Handlebars templates (
.hbsfiles) - Reference in configuration:
{
"customTemplates": "./templates"
}Transform Rules
Modify endpoint names and parameters during generation:
{
"transformRules": [
{
"pattern": "get_user_by_id",
"replacement": "getUser",
"type": "endpoint"
}
]
}Excluding Endpoints
Skip certain endpoints during generation:
{
"excludeEndpoints": [
"GET:/health",
"POST:/internal/*"
]
}Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details.
