From d23fb0cfbbc03fbc843c14a8927cc22803d7fb50 Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Tue, 16 Jun 2026 17:52:28 +0200 Subject: [PATCH] fix for variables not being passed --- documentation/MCP.md | 11 +++++++---- mcp_server/client.py | 14 +++++++------- mcp_server/server.py | 13 ++++++------- mcp_server/tools.py | 11 ++++++----- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/documentation/MCP.md b/documentation/MCP.md index a164557..a9ca85b 100644 --- a/documentation/MCP.md +++ b/documentation/MCP.md @@ -203,7 +203,7 @@ The MCP server provides these tools to AI assistants: |------|-------------| | `list_templates` | List available templates | | `get_template` | Get template content | -| `create_note_from_template` | Create a note from a template with variable substitution | +| `create_note_from_template` | Create a note from a template (built-in placeholders only) | ### System @@ -291,15 +291,18 @@ Get recently modified notes. Useful for context about what you've been working o ### `create_note_from_template` -Create a new note from a template with variable substitution. +Create a new note from a template. Built-in placeholders are substituted +server-side. Need to inject custom content? Call `update_note` after creation. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `template_name` | string | Yes | Template name (e.g., "meeting-notes") | | `note_path` | string | Yes | Path for the new note | -| `variables` | object | No | Variables to substitute (e.g., `{"project": "Alpha"}`) | -**Built-in placeholders:** `{{date}}`, `{{time}}`, `{{datetime}}`, `{{title}}`, `{{folder}}` +**Built-in placeholders:** `{{title}}`, `{{date}}`, `{{time}}`, `{{datetime}}`, +`{{timestamp}}`, `{{year}}`, `{{month}}`, `{{day}}`, `{{folder}}`, plus the +`strftime` escape hatch — `{{date:FMT}}`, `{{time:FMT}}`, `{{datetime:FMT}}` +where `FMT` is a Python `strftime()` format string. See [TEMPLATES.md](TEMPLATES.md). **Example prompt:** "Create a new meeting note for Project Alpha using the meeting-notes template" diff --git a/mcp_server/client.py b/mcp_server/client.py index 69012e3..3753565 100644 --- a/mcp_server/client.py +++ b/mcp_server/client.py @@ -241,16 +241,19 @@ class NoteDiscoveryClient: self, template_name: str, note_path: str, - variables: dict | None = None ) -> APIResponse: """ Create a note from a template. - + + Built-in placeholders ({{title}}, {{date}}, {{datetime}}, + {{folder}}, {{date:FMT}}, etc.) are substituted server-side + by apply_template_placeholders. There is no per-call variable + injection; use update_note after creation for custom content. + Args: template_name: Name of the template note_path: Path for the new note - variables: Variables to substitute in the template - + Returns: APIResponse with creation result """ @@ -259,9 +262,6 @@ class NoteDiscoveryClient: "templateName": template_name, "notePath": note_path, } - if variables: - data["variables"] = variables - return self._request("POST", "/api/templates/create-note", data=data) # ========================================================================= diff --git a/mcp_server/server.py b/mcp_server/server.py index e5a1e25..00a52cd 100644 --- a/mcp_server/server.py +++ b/mcp_server/server.py @@ -625,20 +625,19 @@ class MCPServer: """Create a note from a template.""" template_name = args.get("template_name", "") note_path = args.get("note_path", "") - variables = args.get("variables", {}) - + if not template_name: return "Error: template_name is required" - + is_valid, error = self._validate_path(note_path) if not is_valid: return f"Error: note_path - {error}" - - response = self.client.create_note_from_template(template_name, note_path, variables) - + + response = self.client.create_note_from_template(template_name, note_path) + if not response.success: return f"Failed to create note from template: {response.error}" - + return f"✅ Note created from template '{template_name}': {note_path}" def _tool_health_check(self, args: dict) -> str: diff --git a/mcp_server/tools.py b/mcp_server/tools.py index 360b580..983dacd 100644 --- a/mcp_server/tools.py +++ b/mcp_server/tools.py @@ -238,7 +238,12 @@ TOOLS: list[dict[str, Any]] = [ }, { "name": "create_note_from_template", - "description": "Create a new note from a template with variable substitution. Variables in the template like {{variable_name}} will be replaced.", + "description": ( + "Create a new note from a template. Built-in placeholders like " + "{{title}}, {{date}}, {{datetime}}, {{folder}}, {{date:FMT}} are " + "substituted automatically (FMT is a Python strftime string). " + "Use update_note afterwards if you need to inject custom content." + ), "inputSchema": { "type": "object", "properties": { @@ -249,10 +254,6 @@ TOOLS: list[dict[str, Any]] = [ "note_path": { "type": "string", "description": "Path for the new note (e.g., 'meetings/2024-03-13.md')" - }, - "variables": { - "type": "object", - "description": "Variables to substitute in the template (e.g., {\"project\": \"Alpha\", \"date\": \"2024-03-13\"})" } }, "required": ["template_name", "note_path"]