Merge branch 'fix/mcp-template-drop-variables' into fix/mcp-server-cleanup

This commit is contained in:
Gamosoft 2026-06-16 18:09:56 +02:00
commit 34cd14bc13
4 changed files with 26 additions and 23 deletions

View File

@ -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
@ -292,15 +292,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"

View File

@ -248,15 +248,18 @@ 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
@ -266,9 +269,6 @@ class NoteDiscoveryClient:
"templateName": template_name,
"notePath": note_path,
}
if variables:
data["variables"] = variables
return self._request("POST", "/api/templates/create-note", data=data)
# =========================================================================

View File

@ -627,7 +627,6 @@ 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"
@ -636,7 +635,7 @@ class MCPServer:
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}"

View File

@ -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"]