Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: typing for list params #12

Merged
merged 4 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[project]
name = "mcp-server-appwrite"
version = "0.1.3"
version = "0.1.4"
description = "MCP (Model Context Protocol) server for Appwrite"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"appwrite>=9.0.2",
"docstring-parser>=0.16",
"mcp[cli]>=1.3.0",
]

Expand Down
2 changes: 1 addition & 1 deletion src/mcp_server_appwrite/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def _run():
write_stream,
InitializationOptions(
server_name="appwrite",
server_version="0.1.3",
server_version="0.1.4",
capabilities=server.get_capabilities(
notification_options=NotificationOptions(),
experimental_capabilities={},
Expand Down
9 changes: 7 additions & 2 deletions src/mcp_server_appwrite/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, get_type_hints, Dict, List, Optional, Union
import inspect
from mcp.types import Tool
from docstring_parser import parse

class Service():
"""Base class for all Appwrite services"""
Expand Down Expand Up @@ -86,7 +87,7 @@ def list_tools(self) -> Dict[str, Dict]:
# Get the overridden name if it exists
tool_name = self._method_name_overrides.get(name, f"{self.service_name}_{name}")

docstring = (original_func.__doc__ or "No description available").strip()
docstring = parse(original_func.__doc__)
signature = inspect.signature(original_func)
type_hints = get_type_hints(original_func)

Expand All @@ -100,13 +101,17 @@ def list_tools(self) -> Dict[str, Dict]:
param_type = type_hints.get(param_name, str)
properties[param_name] = self.python_type_to_json_schema(param_type)
properties[param_name]["description"] = f"Parameter '{param_name}'"

for doc_param in docstring.params:
if doc_param.arg_name == param_name:
properties[param_name]["description"] = doc_param.description

if param.default is param.empty:
required.append(param_name)

tool_definition = Tool(
name=tool_name,
description=f"{docstring}",
description=f"{docstring.short_description or "No description available"}",
inputSchema={
"type": "object",
"properties": properties,
Expand Down
13 changes: 12 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.