Skip to main content
Glama
semanticintent

Semantic D1 MCP

Official

get_table_relationships

Extract and analyze foreign key relationships between tables in Cloudflare D1 databases to understand data connections and dependencies.

Instructions

Extract and analyze foreign key relationships between tables in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYesDatabase environment to analyze
tableNameNoOptional: Filter relationships for specific table

Implementation Reference

  • Core handler logic that executes the tool: fetches schema from cache or repository, extracts relationships using RelationshipAnalyzer, filters by optional tableName, formats into DTOs, and returns structured response.
    async execute(request: GetRelationshipsRequest): Promise<RelationshipsResponse> {
    	const environment = request.environment;
    
    	// Get or fetch schema (with caching)
    	const schema = await this.getSchema(environment);
    
    	// Extract relationships using domain service
    	const allRelationships = this.relationshipAnalyzer.extractRelationships([...schema.tables]);
    
    	// Filter by table if specified
    	const relationships = request.tableName
    		? this.filterRelationshipsByTable(allRelationships, request.tableName)
    		: allRelationships;
    
    	// Format and return response
    	return {
    		databaseName: schema.name,
    		environment: schema.environment,
    		relationships: relationships.map((rel) => this.formatRelationship(rel)),
    		relationshipCount: relationships.length,
    	};
    }
  • Registers the get_table_relationships tool in the MCP server's listTools response, defining its name, description, and input schema.
    {
    	name: 'get_table_relationships',
    	description:
    		'Extract and analyze foreign key relationships between tables in the database',
    	inputSchema: {
    		type: 'object',
    		properties: {
    			environment: {
    				type: 'string',
    				enum: ['development', 'staging', 'production'],
    				description: 'Database environment to analyze',
    			},
    			tableName: {
    				type: 'string',
    				description: 'Optional: Filter relationships for specific table',
    			},
    		},
    		required: ['environment'],
    	},
    },
  • MCP-specific tool handler that parses tool call arguments, invokes GetRelationshipsUseCase, and formats response as MCP content.
    private async handleGetRelationships(args: unknown) {
    	const { environment, tableName } = args as {
    		environment: string;
    		tableName?: string;
    	};
    
    	const result = await this.getRelationshipsUseCase.execute({
    		environment: parseEnvironment(environment),
    		tableName,
    	});
    
    	return {
    		content: [
    			{
    				type: 'text',
    				text: JSON.stringify(result, null, 2),
    			},
    		],
    	};
    }
  • Type definition for the input parameters to the use case handler, matching the MCP input schema.
    export interface GetRelationshipsRequest {
    	environment: Environment;
    	tableName?: string;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'extract and analyze' but doesn't clarify what analysis entails, whether it's read-only or has side effects, performance implications, or output format. For a tool with no annotations, this leaves significant behavioral gaps.

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 a single, efficient sentence with zero waste. It's front-loaded with the core purpose and uses precise language. Every word earns its place, making it highly concise and well-structured.

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 moderate complexity (analyzing database relationships), no annotations, and no output schema, the description is minimally adequate. It states the purpose clearly but lacks details on behavior, output, or usage context. It meets the bare minimum for a read-oriented tool but doesn't fully compensate for missing structured data.

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 thoroughly. The description adds no additional meaning beyond what the schema provides—it doesn't explain parameter interactions or usage nuances. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/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 ('extract and analyze') and resources ('foreign key relationships between tables in the database'). It distinguishes from siblings like 'analyze_database_schema' by focusing specifically on relationships rather than general schema analysis. However, it doesn't explicitly differentiate from all siblings like 'validate_database_schema' or 'suggest_schema_optimizations'.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any of the sibling tools, nor does it specify use cases, prerequisites, or exclusions. The agent must infer usage from the purpose alone without explicit direction.

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/semanticintent/semantic-d1-mcp'

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