save_project_context
Store project-specific information with relationships to maintain context across sessions in Claude Server MCP.
Instructions
Save project-specific context with relationships
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique identifier for the context | |
| projectId | Yes | Project identifier | |
| content | Yes | Context content to save | |
| parentContextId | No | Optional ID of parent context | |
| references | No | Optional related context IDs | |
| tags | No | Optional tags for categorizing | |
| metadata | No | Optional additional metadata |
Implementation Reference
- src/index.ts:295-334 (handler)Handler for the 'save_project_context' tool. Extracts input arguments, constructs a ProjectContext object, saves it using the saveContext method, and returns a confirmation message.case 'save_project_context': { const { id, projectId, content, parentContextId, references, tags, metadata, } = request.params.arguments as { id: string; projectId: string; content: string; parentContextId?: string; references?: string[]; tags?: string[]; metadata?: Record<string, unknown>; }; const context: ProjectContext = { id, projectId, content, timestamp: new Date().toISOString(), parentContextId, references, tags, metadata, }; await this.saveContext(context); return { content: [ { type: 'text', text: `Project context saved with ID: ${id}`, }, ], }; }
- src/index.ts:175-214 (registration)Tool registration in the ListTools response, including name, description, and full input schema for 'save_project_context'.{ name: 'save_project_context', description: 'Save project-specific context with relationships', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Unique identifier for the context', }, projectId: { type: 'string', description: 'Project identifier', }, content: { type: 'string', description: 'Context content to save', }, parentContextId: { type: 'string', description: 'Optional ID of parent context', }, references: { type: 'array', items: { type: 'string' }, description: 'Optional related context IDs', }, tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags for categorizing', }, metadata: { type: 'object', description: 'Optional additional metadata', }, }, required: ['id', 'projectId', 'content'], }, },
- src/index.ts:21-25 (schema)TypeScript interface definition for ProjectContext, used in the tool's handler for type safety.interface ProjectContext extends BaseContext { projectId: string; parentContextId?: string; references?: string[]; }
- src/index.ts:103-112 (helper)Core helper method that handles persisting the context to a JSON file and updating the central index. Invoked by the tool handler.private async saveContext(context: Context) { await this.ensureDirectories(); const contextPath = await this.getContextPath( context.id, 'projectId' in context ? context.projectId : undefined ); await fs.writeFile(contextPath, JSON.stringify(context, null, 2), 'utf-8'); await this.updateIndex(context); }