add-note
Create and store a new note by specifying its name and content, enabling quick organization and retrieval within the Notes MCP Server's streamlined storage system.
Instructions
Add a new note
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| name | Yes |
Input Schema (JSON Schema)
{
"properties": {
"content": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"name",
"content"
],
"type": "object"
}
Implementation Reference
- The @server.call_tool() decorated handler function that executes the 'add-note' tool logic: extracts name and content from arguments, stores in global notes dict, sends resource change notification, and returns confirmation text.@server.call_tool() async def handle_call_tool( name: str, arguments: dict | None ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """ Handle tool execution requests. Tools can modify server state and notify clients of changes. """ if name != "add-note": raise ValueError(f"Unknown tool: {name}") if not arguments: raise ValueError("Missing arguments") note_name = arguments.get("name") content = arguments.get("content") if not note_name or not content: raise ValueError("Missing name or content") # Update server state notes[note_name] = content # Notify clients that resources have changed await server.request_context.session.send_resource_list_changed() return [ types.TextContent( type="text", text=f"Added note '{note_name}' with content: {content}", ) ]
- JSON Schema defining the input parameters for the 'add-note' tool: required 'name' and 'content' as strings.inputSchema={ "type": "object", "properties": { "name": {"type": "string"}, "content": {"type": "string"}, }, "required": ["name", "content"], },
- src/mcp_server_on_raspi/server.py:102-116 (registration)The 'add-note' tool is registered in the @server.list_tools() handler by returning a types.Tool instance with its name, description, and schema.return [ types.Tool( name="add-note", description="Add a new note", inputSchema={ "type": "object", "properties": { "name": {"type": "string"}, "content": {"type": "string"}, }, "required": ["name", "content"], }, ) ]
- Global notes dictionary used by the 'add-note' tool to store note name-content pairs.# Store notes as a simple key-value dict to demonstrate state management notes: dict[str, str] = {}