Skip to content

describe_branch leaves show_db_tree function in user's database #196

@RISCfuture

Description

@RISCfuture

Description

The describe_branch tool creates a public.show_db_tree() function in the user's database via DESCRIBE_DATABASE_STATEMENTS in landing/mcp-src/tools/utils.ts, but never cleans it up afterward. The function persists in the database indefinitely.

Impact

For projects that use schema introspection tools to generate types from the live database (e.g., Kanel), the leftover show_db_tree function gets picked up and generates unexpected type files. This causes spurious diffs in PRs and can break CI checks that validate generated code matches the declared schema.

Steps to reproduce

  1. Connect an MCP client to a Neon database using the Neon MCP server
  2. Use the describe_branch tool
  3. Inspect the database: SELECT routine_name FROM information_schema.routines WHERE routine_schema = 'public' AND routine_name = 'show_db_tree';
  4. The function exists and persists after the tool completes

Suggested fix

Either:

  • Drop the function after use (DROP FUNCTION IF EXISTS public.show_db_tree();)
  • Use a temporary mechanism (e.g., run the logic inline as a CTE/subquery instead of creating a persistent function)
  • Create the function in a non-public schema (e.g., neon_mcp) that's less likely to be introspected by user tooling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions