Skip to main content
Glama

detect_schema

Convert SQL CREATE TABLE statements or JSON samples into structured schemas for generating test data that matches existing database structures.

Instructions

Convert an existing database schema or JSON sample into MockHero's schema format.

Send a SQL CREATE TABLE statement and get back the structured schema ready to use with generate_test_data. Or send a sample JSON record and MockHero will infer the field types.

This is useful when you have migration files or an existing database and want to generate test data that matches your schema without manually writing the definition.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlNoSQL CREATE TABLE statement(s) to convert
sample_jsonNoExample JSON record to infer schema from

Implementation Reference

  • The handler function that implements the logic for 'detect_schema', processing either SQL or JSON input to generate a schema.
    async function handleDetectSchema(
      args: Record<string, unknown>
    ): Promise<ToolResult> {
      const { sql, sample_json } = args;
    
      if (!sql && !sample_json) {
        return err(
          "Either 'sql' (SQL CREATE TABLE statements) or 'sample_json' (JSON sample data) is required."
        );
      }
    
      if (sql && typeof sql === "string") {
        const schema = detectFromSql(sql);
        if (schema.tables.length === 0) {
          return err(
            "Could not detect any tables from the provided SQL. Make sure it contains valid CREATE TABLE statements."
          );
        }
        return ok(schema);
      }
    
      if (sample_json) {
        const schema = detectFromJson(sample_json);
        return ok(schema);
      }
    
      return err("Invalid input. Provide 'sql' as a string or 'sample_json' as an object.");
    }
  • The tool execution registration where the 'detect_schema' tool is mapped to the 'handleDetectSchema' function.
    case "detect_schema":
      return handleDetectSchema(args);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the tool's function (conversion/inference) and output ('structured schema ready to use with generate_test_data'), but lacks details on error handling, performance limits, or authentication needs, leaving some behavioral aspects unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose, followed by usage examples and a utility statement. Every sentence adds value without redundancy, making it efficient and easy to understand.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (conversion/inference with two parameters) and no output schema, the description adequately covers the purpose and usage but lacks details on the output format, error cases, or integration with sibling tools like generate_test_data, leaving some contextual gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (sql and sample_json) well. The description adds context by explaining that sql is for 'SQL CREATE TABLE statement(s)' and sample_json is for 'infer[ring] the field types', but this mostly repeats schema info without adding deeper semantics like format constraints or examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('convert', 'infer') and resources ('SQL CREATE TABLE statement', 'sample JSON record'), distinguishing it from siblings like generate_test_data or list_field_types by focusing on schema conversion rather than data generation or listing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('when you have migration files or an existing database'), but it does not explicitly state when not to use it or name specific alternatives among the sibling tools, such as using generate_from_template for different purposes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dinosaur24/mockhero'

If you have feedback or need assistance with the MCP directory API, please join our Discord server