Skip to main content
Glama
InsForge

Insforge MCP Server

run-raw-sql

Execute raw SQL queries with optional parameters to directly modify database data. Requires admin access and caution due to direct database interaction.

Instructions

Execute raw SQL query with optional parameters. Admin access required. Use with caution as it can modify data directly.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNoAPI key for authentication (optional if provided via --api_key)
queryYes
paramsNo

Implementation Reference

  • The handler function for the 'run-raw-sql' tool. It authenticates using the API key, constructs a RawSQLRequest with the provided query and parameters, sends a POST request to the backend API endpoint `/api/database/advance/rawsql`, handles the response, adds background context if applicable, and returns formatted success/error messages.
    withUsageTracking('run-raw-sql', async ({ apiKey, query, params }) => {
      try {
        const actualApiKey = getApiKey(apiKey);
    
        const requestBody: RawSQLRequest = {
          query,
          params: params || [],
        };
    
        const response = await fetch(`${API_BASE_URL}/api/database/advance/rawsql`, {
          method: 'POST',
          headers: {
            'x-api-key': actualApiKey,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(requestBody),
        });
    
        const result = await handleApiResponse(response);
    
        return await addBackgroundContext({
          content: [
            {
              type: 'text',
              text: formatSuccessMessage('SQL query executed', result),
            },
          ],
        });
      } catch (error) {
        const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: 'text',
              text: `Error executing SQL query: ${errMsg}`,
            },
          ],
          isError: true,
        };
      }
    })
  • Input parameters schema defined using Zod. Includes an optional 'apiKey' field and spreads the shape of 'rawSQLRequestSchema' which provides 'query' (string) and 'params' (array) fields for the SQL execution.
    {
      apiKey: z
        .string()
        .optional()
        .describe('API key for authentication (optional if provided via --api_key)'),
      ...rawSQLRequestSchema.shape,
    },
  • Registration of the 'run-raw-sql' tool on the MCP server using server.tool(). Specifies the tool name, description, input schema, and references the wrapped handler function with usage tracking.
    server.tool(
      'run-raw-sql',
      'Execute raw SQL query with optional parameters. Admin access required. Use with caution as it can modify data directly.',
      {
        apiKey: z
          .string()
          .optional()
          .describe('API key for authentication (optional if provided via --api_key)'),
        ...rawSQLRequestSchema.shape,
      },
      withUsageTracking('run-raw-sql', async ({ apiKey, query, params }) => {
        try {
          const actualApiKey = getApiKey(apiKey);
    
          const requestBody: RawSQLRequest = {
            query,
            params: params || [],
          };
    
          const response = await fetch(`${API_BASE_URL}/api/database/advance/rawsql`, {
            method: 'POST',
            headers: {
              'x-api-key': actualApiKey,
              'Content-Type': 'application/json',
            },
            body: JSON.stringify(requestBody),
          });
    
          const result = await handleApiResponse(response);
    
          return await addBackgroundContext({
            content: [
              {
                type: 'text',
                text: formatSuccessMessage('SQL query executed', result),
              },
            ],
          });
        } catch (error) {
          const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [
              {
                type: 'text',
                text: `Error executing SQL query: ${errMsg}`,
              },
            ],
            isError: true,
          };
        }
      })
    );
Behavior4/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 effectively adds context beyond what the input schema provides: it specifies 'Admin access required' (auth needs) and 'Use with caution as it can modify data directly' (destructive potential and risk warning). This covers key behavioral traits like permissions and safety, though it lacks details on rate limits or response format.

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 highly concise and front-loaded: three short sentences that each add value—stating the purpose, access requirements, and caution. There is no wasted text, and it efficiently communicates essential information without redundancy.

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 (raw SQL execution with potential data modification), no annotations, no output schema, and low schema coverage, the description is moderately complete. It covers purpose, auth, and risks, but lacks details on return values, error handling, or specific usage examples. This is adequate for a basic understanding but has clear gaps for safe and effective use.

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 low (33%), with only 'apiKey' having a description in the schema. The description adds minimal parameter semantics: it mentions 'optional parameters' but doesn't explain what 'query' or 'params' entail beyond their names. It partially compensates by hinting at usage context, but doesn't fully address the coverage gap, resulting in a baseline score.

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: 'Execute raw SQL query with optional parameters.' It specifies the verb ('Execute') and resource ('raw SQL query'), distinguishing it from siblings like get-table-schema or create-function. However, it doesn't explicitly differentiate from all siblings (e.g., bulk-upsert might also involve SQL-like operations), keeping it from a perfect score.

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

Usage Guidelines3/5

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

The description provides some usage context: 'Admin access required. Use with caution as it can modify data directly.' This implies when to use (for raw SQL execution with admin privileges) and cautions about risks. However, it doesn't explicitly state when to use alternatives (e.g., use get-table-schema for read-only schema info) or when not to use this tool, leaving guidance incomplete.

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/InsForge/insforge-mcp'

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