thedotmack/claude-mem · error
Missing required argument: name
Error message
Missing required argument: name
What it means
The prime_corpus MCP tool requires a 'name' argument identifying the knowledge corpus to prime. The handler destructures name from args and throws this error when it is missing, not a string, or blank. The schema also declares required: ['name'].
Solutions
- Pass the corpus name: { name: 'my-corpus', ...primingOptions }
- Match the exact key 'name' — not corpusName, corpus, or id
- Verify the corpus exists / was created before priming by that exact name
- Validate at the call site: if (!name?.trim()) throw before invoking the tool
Example fix
// before
await callTool('prime_corpus', { sources: ['docs/'] });
// after
await callTool('prime_corpus', { name: 'project-docs', sources: ['docs/'] }); Defensive patterns
Strategy: validation
Validate before calling
function canPrimeCorpus(args) {
return typeof args?.name === 'string' && args.name.trim().length > 0;
}
if (!canPrimeCorpus(args)) throw new Error('Provide the corpus name before calling prime_corpus'); Type guard
function hasCorpusName(args: unknown): args is { name: string } & Record<string, unknown> {
return typeof (args as any)?.name === 'string' && (args as any).name.trim().length > 0;
} Try / catch
try {
return await callTool('prime_corpus', { name, ...options });
} catch (e) {
if (e instanceof Error && e.message === 'Missing required argument: name') {
console.error('prime_corpus requires a non-empty corpus name');
return null;
}
throw e;
} Prevention
- Always pass the corpus name under the exact key 'name'
- Resolve the name from config with a non-empty default check
- List available corpora first if unsure of the exact name
- Enable MCP client-side schema validation so required: ['name'] is caught before dispatch
When it happens
Trigger: Calling prime_corpus with args lacking 'name', name = undefined/null, a non-string, or an empty/whitespace string (check: typeof name !== 'string' || name.trim() === '').
Common situations: Callers passing only priming options (the rest spread) and forgetting the corpus name; using 'corpus' or 'corpusName' as the key; an LLM omitting the field despite the required schema entry; name derived from an empty config value.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- " " is required
- observation_context: "query" is required
- observation_generation_status: "jobId" is required
- observation_record_event: "eventType" is required
- observation_search: "query" is required
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/e6eeb20073e1540b.
Report an issue: GitHub.
Appendix: source
Thrown at src/servers/mcp-server.ts:860
},
handler: async (args: any) => {
return await callWorker('/api/corpus', { query: args });
}
},
{
name: 'prime_corpus',
description: 'Prime a knowledge corpus — creates an AI session loaded with the corpus knowledge. Must be called before query_corpus.',
inputSchema: {
type: 'object',
properties: {
name: { type: 'string', description: 'Name of the corpus to prime' }
},
required: ['name'],
additionalProperties: true
},
handler: async (args: any) => {
const { name, ...rest } = args;
if (typeof name !== 'string' || name.trim() === '') throw new Error('Missing required argument: name');
return await callWorker(`/api/corpus/${encodeURIComponent(name)}/prime`, { body: rest });
}
},
{
name: 'query_corpus',
description: 'Ask a question to a primed knowledge corpus. The corpus must be primed first with prime_corpus.',
inputSchema: {
type: 'object',
properties: {
name: { type: 'string', description: 'Name of the corpus to query' },
question: { type: 'string', description: 'The question to ask' }
},
required: ['name', 'question'],
additionalProperties: true
},
handler: async (args: any) => {
const { name, ...rest } = args;
if (typeof name !== 'string' || name.trim() === '') throw new Error('Missing required argument: name');View on GitHub (pinned to d8bc9755e7)