added pyright and fixed type errors
This commit is contained in:
@@ -8,12 +8,10 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
from mcp.server import Server
|
||||
from mcp.types import (
|
||||
Resource,
|
||||
Tool,
|
||||
TextContent,
|
||||
ImageContent,
|
||||
EmbeddedResource,
|
||||
LoggingLevel,
|
||||
)
|
||||
|
||||
load_dotenv()
|
||||
@@ -52,16 +50,6 @@ add_tool_handler(tools.PatchContentToolHandler())
|
||||
add_tool_handler(tools.AppendContentToolHandler())
|
||||
add_tool_handler(tools.ComplexSearchToolHandler())
|
||||
|
||||
#@app.list_resources()
|
||||
#async def list_resources() -> list[Resource]:
|
||||
# return [
|
||||
# Resource(
|
||||
# uri="obisidian:///note/app.log",
|
||||
# name="Application Logs",
|
||||
# mimeType="text/plain"
|
||||
# )
|
||||
# ]
|
||||
|
||||
@app.list_tools()
|
||||
async def list_tools() -> list[Tool]:
|
||||
"""List available tools."""
|
||||
@@ -69,7 +57,7 @@ async def list_tools() -> list[Tool]:
|
||||
return [th.get_tool_description() for th in tool_handlers.values()]
|
||||
|
||||
@app.call_tool()
|
||||
async def call_tool(name: str, arguments: Any) -> Sequence[TextContent]:
|
||||
async def call_tool(name: str, arguments: Any) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
|
||||
"""Handle tool calls for command line run."""
|
||||
|
||||
if not isinstance(arguments, dict):
|
||||
|
@@ -4,14 +4,13 @@ from mcp.types import (
|
||||
TextContent,
|
||||
ImageContent,
|
||||
EmbeddedResource,
|
||||
LoggingLevel,
|
||||
)
|
||||
import json
|
||||
import os
|
||||
from . import obsidian
|
||||
|
||||
api_key = os.getenv("OBSIDIAN_API_KEY")
|
||||
if not api_key:
|
||||
api_key = os.getenv("OBSIDIAN_API_KEY", "")
|
||||
if api_key == "":
|
||||
raise ValueError("OBSIDIAN_API_KEY environment variable required")
|
||||
|
||||
TOOL_LIST_FILES_IN_VAULT = "list_files_in_vault"
|
||||
@@ -219,7 +218,7 @@ class AppendContentToolHandler(ToolHandler):
|
||||
raise RuntimeError("filepath and content arguments required")
|
||||
|
||||
api = obsidian.Obsidian(api_key=api_key)
|
||||
api.append_content(args["filepath"], args["content"])
|
||||
api.append_content(args.get("filepath", ""), args["content"])
|
||||
|
||||
return [
|
||||
TextContent(
|
||||
@@ -274,11 +273,11 @@ class PatchContentToolHandler(ToolHandler):
|
||||
|
||||
api = obsidian.Obsidian(api_key=api_key)
|
||||
api.patch_content(
|
||||
args["filepath"],
|
||||
args["operation"],
|
||||
args["target_type"],
|
||||
args["target"],
|
||||
args["content"]
|
||||
args.get("filepath", ""),
|
||||
args.get("operation", ""),
|
||||
args.get("target_type", ""),
|
||||
args.get("target", ""),
|
||||
args.get("content", "")
|
||||
)
|
||||
|
||||
return [
|
||||
@@ -317,7 +316,7 @@ class ComplexSearchToolHandler(ToolHandler):
|
||||
raise RuntimeError("query argument missing in arguments")
|
||||
|
||||
api = obsidian.Obsidian(api_key=api_key)
|
||||
results = api.search_json(args["query"])
|
||||
results = api.search_json(args.get("query", ""))
|
||||
|
||||
return [
|
||||
TextContent(
|
||||
|
Reference in New Issue
Block a user