abhigyanpatwari/GitNexus · error

Unknown prompt: ${name}

Error message

Unknown prompt: ${name}

What it means

The MCP prompts/get handler in gitnexus/src/mcp/server.ts knows exactly two prompts — detect_impact (args: scope, base_ref) and generate_map (args: repo). Any other prompt name falls past both if-blocks and hits this throw.

Source

Thrown at gitnexus/src/mcp/server.ts:332

            role: 'user' as const,
            content: {
              type: 'text' as const,
              text: `Generate architecture documentation for this codebase using the knowledge graph.

Follow these steps:
1. READ \`gitnexus://repo/${repo || '{name}'}/context\` for codebase stats
2. READ \`gitnexus://repo/${repo || '{name}'}/clusters\` to see all functional areas
3. READ \`gitnexus://repo/${repo || '{name}'}/processes\` to see all execution flows
4. For the top 5 most important processes, READ \`gitnexus://repo/${repo || '{name}'}/process/{name}\` for step-by-step traces
5. Generate a mermaid architecture diagram showing the major areas and their connections
6. Write an ARCHITECTURE.md file with: overview, functional areas, key execution flows, and the mermaid diagram`,
            },
          },
        ],
      };
    }

    throw new Error(`Unknown prompt: ${name}`);
  });

  return server;
}

/**
 * Start the MCP server on stdio transport (for CLI use).
 */
/** Force-exit fallback budget if graceful shutdown cleanup hangs. */
const SHUTDOWN_FORCE_EXIT_MS = 5_000;

/** Conventional 128 + signal-number exit codes for graceful termination. */
export const SHUTDOWN_EXIT_CODES = { SIGINT: 130, SIGTERM: 143 } as const;

type SignalRegistrar = (
  event: 'SIGINT' | 'SIGTERM',
  listener: (...args: unknown[]) => void,
) => void;

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Call prompts/list first and use a returned name verbatim
  2. Use exactly 'detect_impact' or 'generate_map'
  3. Update the pinned gitnexus version if docs mention a prompt the server does not expose

Example fix

// before
const p = await client.getPrompt('generate-architecture');

// after
const p = await client.getPrompt('generate_map');
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN_PROMPTS = ['detect_impact', 'generate_map'];
function assertKnownPrompt(name) {
  if (!KNOWN_PROMPTS.includes(name)) throw new Error(`Unknown prompt: ${name}; known: ${KNOWN_PROMPTS.join(', ')}`);
}

Type guard

function isKnownPromptName(name, advertised) {
  return advertised ? advertised.some((p) => p.name === name) : ['detect_impact', 'generate_map'].includes(name);
}

Try / catch

try { return await server.getPrompt(name); }
catch (e) {
  if (e.message.startsWith('Unknown prompt:')) { const list = await server.listPrompts(); throw new Error(`Pick from: ${list.prompts.map((p) => p.name).join(', ')}`); }
  throw e;
}

Prevention

When it happens

Trigger: prompts/get with name 'generate-architecture', 'map', 'impact_detection', or any rename/variant of the two real names; also names sourced from a different GitNexus version's prompt list.

Common situations: An MCP client (or the model driving it) guessing prompt names instead of calling prompts/list; stale hardcoded prompt names after a GitNexus upgrade renamed or removed a prompt; hyphen-vs-underscore confusion.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-08-20). Data as JSON: /api/errors/881ffa8c4ef058bf. Report an issue: GitHub.