Skip to main content
Glama
abushadab

Self-Hosted Supabase MCP Server

by abushadab

get_anon_key

Retrieve the configured Supabase anon key from a self-hosted MCP server to securely interact with its Supabase instance for database queries, migrations, and feature management.

Instructions

Returns the configured Supabase anon key for this server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The async execute function implementing the get_anon_key tool logic. It retrieves the SelfhostedSupabaseClient from context and calls its getAnonKey() method to return the anon key.
    execute: async (input: GetAnonKeyInput, context: ToolContext) => {
        const client = context.selfhostedClient;
        const key = client.getAnonKey(); // Use getter from client
        return { anon_key: key };
    },
  • Zod schemas defining empty input, output with anon_key string field, and static MCP input schema (empty object).
    const GetAnonKeyInputSchema = z.object({});
    type GetAnonKeyInput = z.infer<typeof GetAnonKeyInputSchema>;
    
    // Output schema
    const GetAnonKeyOutputSchema = z.object({
        anon_key: z.string(),
    });
    
    // Static JSON Schema for MCP capabilities
    const mcpInputSchema = {
        type: 'object',
        properties: {},
        required: [],
    };
  • Definition and export of the getAnonKeyTool object, which includes name, description, schemas, and execute handler. This is imported and registered elsewhere.
    export const getAnonKeyTool = {
        name: 'get_anon_key',
        description: 'Returns the configured Supabase anon key for this server.',
        inputSchema: GetAnonKeyInputSchema,
        mcpInputSchema: mcpInputSchema,
        outputSchema: GetAnonKeyOutputSchema,
        execute: async (input: GetAnonKeyInput, context: ToolContext) => {
            const client = context.selfhostedClient;
            const key = client.getAnonKey(); // Use getter from client
            return { anon_key: key };
        },
    }; 
  • src/index.ts:108-108 (registration)
    Registration of getAnonKeyTool in the availableTools object used by the MCP server.
    [getAnonKeyTool.name]: getAnonKeyTool as AppTool,
  • Getter method on SelfhostedSupabaseClient class that returns the configured Supabase anon key, used by the tool handler.
    public getAnonKey(): string {
        return this.options.supabaseAnonKey;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
Behavior2/5

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

With no annotations provided, the description must disclose behavior. It only says 'Returns', implying a read-only operation, but lacks details on potential side effects, authentication requirements, or error conditions. Minimal behavioral context.

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?

Single sentence that is concise and front-loaded with the action and result. No wasted words, effectively communicates the tool's function.

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

Completeness4/5

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

For a simple getter with no parameters and no output schema, the description is largely sufficient. However, it could mention the key's typical use (e.g., for public client access) or the need for a connected instance to fully cover the context.

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

Parameters4/5

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

No parameters exist, so schema coverage is 100%. Baseline for zero-parameter tools is 4; the description adds no parameter-specific meaning but does not need to.

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?

Description clearly states the tool returns the configured Supabase anon key. The verb 'Returns' and resource 'Supabase anon key' are specific and unambiguous, distinguishing it from sibling tools like get_service_key through the explicit mention of 'anon key'.

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?

No guidance on when to use this tool versus alternatives (e.g., get_service_key for service role key). The description does not specify context or prerequisites, such as needing a connected Supabase instance.

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

Deploy Server

Other Tools

Related Tools