Initial commit: Python MCP server (Streamable HTTP, API key, return documents)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
|
||||
def list_templates(templates_dir: str) -> dict:
|
||||
if not os.path.isdir(templates_dir):
|
||||
return {"templates": []}
|
||||
templates: List[str] = []
|
||||
for entry in os.listdir(templates_dir):
|
||||
path = os.path.join(templates_dir, entry)
|
||||
if os.path.isfile(path) and entry.lower().endswith(".docx"):
|
||||
templates.append(entry)
|
||||
templates.sort()
|
||||
return {"templates": templates}
|
||||
|
||||
|
||||
def open_template_path(templates_dir: str, name: str) -> str:
|
||||
path = os.path.join(templates_dir, name)
|
||||
if not os.path.isfile(path):
|
||||
raise ValueError(f"Template not found: {name}")
|
||||
return path
|
||||
Reference in New Issue
Block a user