Merge branch 'fix/mcp-template-drop-variables' into fix/mcp-server-cleanup
This commit is contained in:
commit
34cd14bc13
|
|
@ -203,7 +203,7 @@ The MCP server provides these tools to AI assistants:
|
||||||
|------|-------------|
|
|------|-------------|
|
||||||
| `list_templates` | List available templates |
|
| `list_templates` | List available templates |
|
||||||
| `get_template` | Get template content |
|
| `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
|
### System
|
||||||
|
|
||||||
|
|
@ -292,15 +292,18 @@ Get recently modified notes. Useful for context about what you've been working o
|
||||||
|
|
||||||
### `create_note_from_template`
|
### `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 |
|
| Parameter | Type | Required | Description |
|
||||||
|-----------|------|----------|-------------|
|
|-----------|------|----------|-------------|
|
||||||
| `template_name` | string | Yes | Template name (e.g., "meeting-notes") |
|
| `template_name` | string | Yes | Template name (e.g., "meeting-notes") |
|
||||||
| `note_path` | string | Yes | Path for the new note |
|
| `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"
|
**Example prompt:** "Create a new meeting note for Project Alpha using the meeting-notes template"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,16 +248,19 @@ class NoteDiscoveryClient:
|
||||||
self,
|
self,
|
||||||
template_name: str,
|
template_name: str,
|
||||||
note_path: str,
|
note_path: str,
|
||||||
variables: dict | None = None
|
|
||||||
) -> APIResponse:
|
) -> APIResponse:
|
||||||
"""
|
"""
|
||||||
Create a note from a template.
|
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:
|
Args:
|
||||||
template_name: Name of the template
|
template_name: Name of the template
|
||||||
note_path: Path for the new note
|
note_path: Path for the new note
|
||||||
variables: Variables to substitute in the template
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
APIResponse with creation result
|
APIResponse with creation result
|
||||||
"""
|
"""
|
||||||
|
|
@ -266,9 +269,6 @@ class NoteDiscoveryClient:
|
||||||
"templateName": template_name,
|
"templateName": template_name,
|
||||||
"notePath": note_path,
|
"notePath": note_path,
|
||||||
}
|
}
|
||||||
if variables:
|
|
||||||
data["variables"] = variables
|
|
||||||
|
|
||||||
return self._request("POST", "/api/templates/create-note", data=data)
|
return self._request("POST", "/api/templates/create-note", data=data)
|
||||||
|
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
|
||||||
|
|
@ -627,20 +627,19 @@ class MCPServer:
|
||||||
"""Create a note from a template."""
|
"""Create a note from a template."""
|
||||||
template_name = args.get("template_name", "")
|
template_name = args.get("template_name", "")
|
||||||
note_path = args.get("note_path", "")
|
note_path = args.get("note_path", "")
|
||||||
variables = args.get("variables", {})
|
|
||||||
|
|
||||||
if not template_name:
|
if not template_name:
|
||||||
return "Error: template_name is required"
|
return "Error: template_name is required"
|
||||||
|
|
||||||
is_valid, error = self._validate_path(note_path)
|
is_valid, error = self._validate_path(note_path)
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return f"Error: note_path - {error}"
|
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:
|
if not response.success:
|
||||||
return f"Failed to create note from template: {response.error}"
|
return f"Failed to create note from template: {response.error}"
|
||||||
|
|
||||||
return f"✅ Note created from template '{template_name}': {note_path}"
|
return f"✅ Note created from template '{template_name}': {note_path}"
|
||||||
|
|
||||||
def _tool_health_check(self, args: dict) -> str:
|
def _tool_health_check(self, args: dict) -> str:
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,12 @@ TOOLS: list[dict[str, Any]] = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "create_note_from_template",
|
"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": {
|
"inputSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -249,10 +254,6 @@ TOOLS: list[dict[str, Any]] = [
|
||||||
"note_path": {
|
"note_path": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Path for the new note (e.g., 'meetings/2024-03-13.md')"
|
"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"]
|
"required": ["template_name", "note_path"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue