context_save
Save context entries like conversations, code snippets, suggestions, or errors for project continuity across sessions. Organize with titles, content, and tags for easy retrieval.
Instructions
Save a new context entry for the current project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Context type | |
| title | Yes | Context title | |
| content | Yes | Context content | |
| tags | No | Tags for categorization | |
| session_context_id | No | Link to existing context ID |
Input Schema (JSON Schema)
{
"properties": {
"content": {
"description": "Context content",
"type": "string"
},
"session_context_id": {
"description": "Link to existing context ID",
"type": "string"
},
"tags": {
"description": "Tags for categorization",
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"description": "Context title",
"type": "string"
},
"type": {
"description": "Context type",
"enum": [
"conversation",
"code",
"suggestion",
"error"
],
"type": "string"
}
},
"required": [
"type",
"title",
"content"
],
"type": "object"
}
Implementation Reference
- src/mcp_server/server.py:426-464 (handler)Executes the context_save tool: parses input arguments, constructs ContextContent and ContextEntry based on type, adds session info and optional link, then saves via storage.if name == "context_save": from models import ContextContent context_type = arguments["type"] title = arguments["title"] content_text = arguments["content"] tags = arguments.get("tags", []) session_context_id = arguments.get("session_context_id") # Parse content based on type if context_type == "conversation": content = ContextContent(messages=[content_text]) elif context_type == "code": content = ContextContent(code={"snippet": content_text}) elif context_type == "suggestion": content = ContextContent(suggestions=content_text) elif context_type == "error": content = ContextContent(errors=content_text) else: content = ContextContent(messages=[content_text]) # Create context entry with session info context = ContextEntry( type=context_type, title=title, content=content, tags=tags, project_path=os.getcwd(), session_id=self.session_id, session_timestamp=self.session_timestamp, ) # Link to session context if provided if session_context_id: context.metadata["session_context_id"] = session_context_id self.storage.save_context(context) return [TextContent(type="text", text=f"ā Context saved (ID: {context.id})")]
- src/mcp_server/server.py:174-199 (registration)Registers the context_save tool in list_tools() with name, description, and input schema defining required fields and options.Tool( name="context_save", description="Save a new context entry for the current project", inputSchema={ "type": "object", "properties": { "type": { "type": "string", "description": "Context type", "enum": ["conversation", "code", "suggestion", "error"], }, "title": {"type": "string", "description": "Context title"}, "content": {"type": "string", "description": "Context content"}, "tags": { "type": "array", "items": {"type": "string"}, "description": "Tags for categorization", }, "session_context_id": { "type": "string", "description": "Link to existing context ID", }, }, "required": ["type", "title", "content"], }, ),
- src/mcp_server/server.py:177-198 (schema)JSON schema for input validation of context_save tool parameters.inputSchema={ "type": "object", "properties": { "type": { "type": "string", "description": "Context type", "enum": ["conversation", "code", "suggestion", "error"], }, "title": {"type": "string", "description": "Context title"}, "content": {"type": "string", "description": "Context content"}, "tags": { "type": "array", "items": {"type": "string"}, "description": "Tags for categorization", }, "session_context_id": { "type": "string", "description": "Link to existing context ID", }, }, "required": ["type", "title", "content"], },