mcp_liam

iberianpig/mcp_liam

3.2

If you are the rightful owner of mcp_liam and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This is an MCP server for analyzing database schemas generated by Liam ERD.

Tools
5
Resources
0
Prompts
0

MCP Liam

This is an MCP server for analyzing database schemas generated by Liam ERD.

Overview

This MCP server reads the schema.json file generated by Liam ERD and provides the following functionalities:

  • Retrieving a list of tables
  • Getting detailed table schemas
  • Searching tables and columns by name
  • Analyzing table relationships
  • Analyzing model dependencies

Setup

1. Install dependencies

Since this script uses bundler/inline, the required gems will be automatically installed.

2. Set execution permissions

chmod +x mcp_liam/mcp_liam.rb

3. MCP Configuration

Add the following configuration to your Claude Code config file (~/.config/claude/mcp.json or .claude/mcp.json):

{
  "mcpServers": {
    "liam": {
      "command": "ruby",
      "args": ["/absolute/path/to/mcp_liam.rb"],
      "env": {
        "SCHEMA_PATH": "/absolute/path/to/schema.json"
      }
    }
  }
}

Notes:

  • Paths must be specified as absolute paths.
  • The value of SCHEMA_PATH should point to the path of the schema.json file generated by Liam ERD.

Please also refer to the sample configuration file .mcp.json.example.

Provided Tools

1. list_tables

Retrieves the list of all tables.

Parameters:

  • pattern (optional): A pattern to filter table names (case-insensitive).

Examples:

// Get all tables
list_tables()

// Get tables that contain "user"
list_tables(pattern: "user")

2. get_table_schema

Retrieves the detailed schema for a specific table.

Parameters:

  • table_name (required): The name of the table.

Example:

get_table_schema(table_name: "users")

Output includes:

  • Column list (data types, constraints, comments)
  • Index list
  • Constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE)

3. search_tables

Searches for tables by name or column names.

Parameters:

  • query (required): Search query string.

Examples:

search_tables(query: "email")
search_tables(query: "exercise")

4. get_table_relations

Fetches foreign key relationships involving a specified table.

Parameters:

  • table_name (required): The name of the table.

Example:

get_table_relations(table_name: "exercise_works")

Output includes:

  • Foreign Keys: Tables referenced by this table
  • Referenced By: Relationships where this table is referenced by other tables

5. analyze_model_dependencies

Performs comprehensive dependency analysis on a model.

Parameters:

  • table_name (required): The name of the table.

Example:

analyze_model_dependencies(table_name: "exercises")

Output includes:

  • Basic information (number of columns, indexes)
  • Tables that this table depends on
  • Tables that depend on this table
  • Detailed relationship information

Verification

To verify that the MCP server is working properly:

# Set the schema file path via environment variable
export SCHEMA_PATH=/path/to/schema.json

# Retrieve the list of tables
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_tables","arguments":{}}}' | ruby mcp-server-schema/mcp_schema.rb

# Retrieve schema for a specific table
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_table_schema","arguments":{"table_name":"users"}}}' | ruby mcp-server-schema/mcp_schema.rb

Use Cases

Understanding Data Models

AI: "Tell me about the structure of the exercises table."
→ get_table_schema(table_name: "exercises")

Checking Relationships

AI: "Which tables are related to exercise_works?"
→ get_table_relations(table_name: "exercise_works")

Searching Tables

AI: "Find all tables related to users."
→ search_tables(query: "user")

Dependency Analysis

AI: "Analyze the dependencies of the lessons table."
→ analyze_model_dependencies(table_name: "lessons")

Troubleshooting

Schema File Not Found

Error message:

Schema file not found: /path/to/schema.json

Solution:

  1. Ensure the SCHEMA_PATH environment variable is correctly set.
  2. Verify that the path to the schema file is an absolute path.

JSON Parsing Error

Error message:

Invalid JSON in schema file

Solution:

  1. Check if the schema file at dist/schema.json is corrupted.
  2. Regenerate the schema file.

Technical Details

Technologies Used

  • Ruby
  • mcp gem - Model Context Protocol SDK
  • JSON - for parsing the schema file

Architecture

mcp_schema.rb
├── SchemaLoader: Loads and searches schema files
├── ListTablesTool: Retrieves list of tables
├── GetTableSchemaTool: Fetches detailed table schema
├── SearchTablesTool: Searches tables
├── GetTableRelationsTool: Fetches table relationships
└── AnalyzeModelDependenciesTool: Performs dependency analysis

Schema File Format

{
  "tables": {
    "table_name": {
      "name": "table_name",
      "comment": "Table comment",
      "columns": { ... },
      "indexes": { ... },
      "constraints": { ... }
    }
  }
}

References

  • Liam ERD - Database schema visualization tool