Skip to content

MCP Tools Reference

Complete reference for all APiGen MCP tools.

generate_from_sql

Generate complete API code from SQL schema.

Parameters

ParameterTypeRequiredDefaultDescription
sql_contentstringYes-SQL CREATE TABLE statements
packagestringNocom.example.apiBase package name
output_dirstringNo./generatedOutput directory path
dry_runbooleanNofalsePreview without writing files

Example Request

json
{
  "name": "generate_from_sql",
  "arguments": {
    "sql_content": "CREATE TABLE users (id BIGINT PRIMARY KEY AUTO_INCREMENT, email VARCHAR(255) NOT NULL UNIQUE, username VARCHAR(100) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP); CREATE TABLE posts (id BIGINT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(200) NOT NULL, content TEXT, user_id BIGINT, FOREIGN KEY (user_id) REFERENCES users(id));",
    "package": "com.myapp.blog",
    "output_dir": "./blog-api",
    "dry_run": false
  }
}

Example Response

Generated 26 files for 2 entities

Package: com.myapp.blog
Output: ./blog-api

Files created:
  - src/main/java/com/myapp/blog/users/domain/entity/User.java
  - src/main/java/com/myapp/blog/users/application/dto/UserDTO.java
  - src/main/java/com/myapp/blog/users/application/mapper/UserMapper.java
  - src/main/java/com/myapp/blog/users/application/service/UserService.java
  - src/main/java/com/myapp/blog/users/application/service/UserServiceImpl.java
  - src/main/java/com/myapp/blog/users/infrastructure/repository/UserRepository.java
  - src/main/java/com/myapp/blog/users/infrastructure/controller/UserController.java
  - src/main/java/com/myapp/blog/users/infrastructure/controller/UserControllerImpl.java
  - src/main/java/com/myapp/blog/posts/...
  - src/main/resources/db/migration/V2__create_users_table.sql
  - src/main/resources/db/migration/V3__create_posts_table.sql
  - src/test/java/...

preview_sql

Preview what code will be generated without creating files.

Parameters

ParameterTypeRequiredDefaultDescription
sql_contentstringYes-SQL schema to preview

Example Request

json
{
  "name": "preview_sql",
  "arguments": {
    "sql_content": "CREATE TABLE products (id BIGINT PRIMARY KEY, name VARCHAR(200) NOT NULL, price DECIMAL(10,2));"
  }
}

Example Response

=== Preview: 1 entities ===

Tables found:
  - products -> Product (3 columns)

Entity tables (will generate code):

## Product
Table: products
Columns:
  - id: BIGINT -> Long [PK] [NOT NULL]
  - name: VARCHAR -> String [NOT NULL]
  - price: DECIMAL -> BigDecimal

Files that would be generated per entity:
  - Entity.java
  - EntityDTO.java
  - EntityMapper.java
  - EntityRepository.java
  - EntityService.java
  - EntityServiceImpl.java
  - EntityController.java
  - EntityControllerImpl.java
  - V*__create_*_table.sql (migration)
  - *Test.java (tests)

parse_sql

Parse SQL schema and return structured table information.

Parameters

ParameterTypeRequiredDefaultDescription
sql_contentstringYes-SQL schema to parse

Example Request

json
{
  "name": "parse_sql",
  "arguments": {
    "sql_content": "CREATE TABLE orders (id BIGINT PRIMARY KEY AUTO_INCREMENT, user_id BIGINT NOT NULL, total DECIMAL(10,2) NOT NULL, status VARCHAR(50) DEFAULT 'PENDING', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE);"
  }
}

Example Response

Parsed 1 tables:

## orders
Entity name: Order
Columns:
  - id: BIGINT -> Long [PK] [NOT NULL] [AUTO]
  - user_id: BIGINT -> Long [NOT NULL]
  - total: DECIMAL -> BigDecimal [NOT NULL]
  - status: VARCHAR -> String
  - created_at: TIMESTAMP -> LocalDateTime
Foreign Keys:
  - user_id -> users.id ON DELETE CASCADE

list_languages

List all supported programming languages and frameworks.

Parameters

None required.

Example Request

json
{
  "name": "list_languages",
  "arguments": {}
}

Example Response

Supported languages:

  - java-spring: Java with Spring Boot
  - java-quarkus: Java with Quarkus
  - kotlin-spring: Kotlin with Spring Boot
  - python-fastapi: Python with FastAPI
  - python-django: Python with Django REST Framework
  - typescript-nestjs: TypeScript with NestJS
  - typescript-express: TypeScript with Express
  - csharp-aspnet: C# with ASP.NET Core
  - go-chi: Go with Chi router
  - go-gin: Go with Gin framework
  - php-laravel: PHP with Laravel
  - rust-axum: Rust with Axum

Note: Currently the MCP server uses the Java Spring generator.
Other languages are supported through the CLI.

list_databases

List all supported database types.

Parameters

None required.

Example Request

json
{
  "name": "list_databases",
  "arguments": {}
}

Example Response

Supported databases:

  - postgresql
  - mysql
  - mariadb
  - mongodb
  - sqlite
  - h2
  - oracle
  - sqlserver

Error Handling

All tools return errors in a consistent format:

json
{
  "content": [
    {
      "type": "text",
      "text": "Error: <error message>"
    }
  ],
  "isError": true
}

Common Errors

ErrorCauseSolution
"No tables found in SQL schema"Invalid or empty SQLCheck SQL syntax
"Parse error: ..."SQL parsing failedSimplify SQL or check syntax
"Unknown tool: ..."Invalid tool nameUse listed tool names
"Error: ..."Generation failedCheck error message details

Released under the MIT License.