Skip to content

Commit 127aee2

Browse files
authored
Merge pull request #44 from chughtapan/revert-pr-43
Revert PR #43: Revert FastMCP API compatibility changes
2 parents 03ce8c8 + 7f6fbb7 commit 127aee2

11 files changed

Lines changed: 241 additions & 262 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ override-dependencies = [
4747
"google-genai>=1.33.0", # Override mcpuniverse's google-genai==1.16.1 constraint
4848
"mistralai>=1.7.0", # Override mcpuniverse's mistralai==1.6.0 constraint
4949
"python-dotenv>=1.1.0", # Override mcpuniverse's python-dotenv==1.0.1 constraint
50-
"uvicorn>=0.35.0", # Override mcpuniverse's uvicorn==0.34.0 constraint
5150
"mcp @ git+https://github.com/chughtapan/python-sdk.git@wags-dev", # Align with core dependency
5251
]
5352

src/wags/utils/handlers_generator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def generate_method_stub(tool: Tool) -> str:
7070
"""Generate a method stub for a tool."""
7171
method_name = sanitize_method_name(tool.name)
7272

73-
# Parse parameters from input_schema
73+
# Parse parameters from inputSchema
7474
params = []
7575
params.append("self")
7676

77-
if tool.input_schema and isinstance(tool.input_schema, dict):
78-
properties = tool.input_schema.get("properties", {})
79-
required = tool.input_schema.get("required", [])
77+
if tool.inputSchema and isinstance(tool.inputSchema, dict):
78+
properties = tool.inputSchema.get("properties", {})
79+
required = tool.inputSchema.get("required", [])
8080

8181
# Process required parameters first
8282
for param_name in required:
@@ -119,8 +119,8 @@ def generate_handlers_class(class_name: str, tools: list[Tool]) -> str:
119119
needs_literal = any(
120120
"enum" in prop
121121
for tool in tools
122-
if tool.input_schema and isinstance(tool.input_schema, dict)
123-
for prop in tool.input_schema.get("properties", {}).values()
122+
if tool.inputSchema and isinstance(tool.inputSchema, dict)
123+
for prop in tool.inputSchema.get("properties", {}).values()
124124
)
125125

126126
# Generate imports

tests/benchmarks/appworld/mcp_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async def list_tools() -> list[Tool]:
209209
tool = Tool(
210210
name=api_doc["name"],
211211
description=api_doc["description"],
212-
input_schema=api_doc["input_schema"],
212+
inputSchema=api_doc["input_schema"],
213213
outputSchema=api_doc["output_schema"],
214214
)
215215
tools.append(tool)

tests/benchmarks/bfcl/elicitation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ async def handle(
176176
func_name = self.extract_function_name(message)
177177
self.structured_logger.log_elicitation(func_name, "accepted", ground_truth_params)
178178
return ElicitResult(
179-
action="accept",
180-
content=cast(dict[str, str | int | float | bool | list[str] | None], ground_truth_params),
179+
action="accept", content=cast(dict[str, str | int | float | bool | None], ground_truth_params)
181180
)
182181

183182
# No matching function found or no text params

tests/benchmarks/mcp_universe/test_mcp_universe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _log_message(msg: Any, turn_idx: int, logger: StructuredEventLogger) -> int:
7878
if hasattr(msg, "tool_results") and msg.tool_results:
7979
for tool_id, result in msg.tool_results.items():
8080
content = _extract_text_content(result.content) if hasattr(result, "content") else []
81-
is_error = getattr(result, "is_error", False)
81+
is_error = getattr(result, "isError", False)
8282
logger.log_tool_result(turn_idx, tool_id, content or str(result), is_error)
8383

8484
if getattr(msg, "role", None) == "assistant" and hasattr(msg, "content"):
@@ -139,7 +139,7 @@ async def _run_mcp_universe_test(test_id: str, model: str, temperature: float, o
139139
servers=["github"],
140140
tools=tools_config,
141141
instruction=test_dir / "instruction.txt",
142-
request_params=RequestParams(max_tokens=MAX_TOKENS, max_iterations=MAX_ITERATIONS),
142+
request_params=RequestParams(maxTokens=MAX_TOKENS, max_iterations=MAX_ITERATIONS),
143143
)
144144
async def run_test() -> Path:
145145
async with agent.run() as agent_app:

tests/e2e/test_github_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def test_function() -> None:
5454
# Verify successful response (not blocked by middleware)
5555
assert tool_id in tool_results
5656
result = tool_results[tool_id]
57-
assert not result.is_error
57+
assert not result.isError
5858

5959
await test_function()
6060

@@ -99,7 +99,7 @@ async def test_function() -> None:
9999
# Verify middleware denied access (error response)
100100
assert tool_id in tool_results
101101
result = tool_results[tool_id]
102-
assert result.is_error
102+
assert result.isError
103103

104104
# Verify error message indicates access denial
105105
error_text = get_result_text(result)
@@ -141,7 +141,7 @@ async def test_function() -> None:
141141
# Check if the call succeeded
142142
if tool_id in tool_results:
143143
result = tool_results[tool_id]
144-
if not result.is_error:
144+
if not result.isError:
145145
success_found = True
146146
break
147147

tests/unit/test_proxy.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Tests for proxy server with todo support."""
22

33
import pytest
4-
from fastmcp import Client, FastMCP
4+
from fastmcp import FastMCP
55

66
from wags.proxy import create_proxy
77

@@ -51,13 +51,11 @@ def test_tool() -> str:
5151
assert "TodoWrite" in proxy.instructions
5252
assert "Task Management" in proxy.instructions
5353

54-
# Should have todo tools available via client connection
55-
async with Client(proxy) as client:
56-
tools = await client.list_tools()
57-
tool_names = {t.name for t in tools}
58-
assert "TodoWrite" in tool_names
54+
# Should have todo tools available
55+
tools = await proxy._tool_manager.get_tools()
56+
assert "TodoWrite" in tools
5957
# Should also have original tool
60-
assert "test_tool" in tool_names
58+
assert "test_tool" in tools
6159

6260
def test_create_proxy_with_todos_rejects_instructions(self) -> None:
6361
"""Test that enable_todos=True raises error if server has instructions."""
@@ -77,13 +75,11 @@ async def test_todo_tools_no_prefix(self) -> None:
7775
server = FastMCP("test-server")
7876
proxy = create_proxy(server, enable_todos=True)
7977

80-
async with Client(proxy) as client:
81-
tools = await client.list_tools()
82-
tool_names = {t.name for t in tools}
78+
tools = await proxy._tool_manager.get_tools()
8379

8480
# Tools should be TodoWrite, not todo_TodoWrite
85-
assert "TodoWrite" in tool_names
86-
assert "todo_TodoWrite" not in tool_names
81+
assert "TodoWrite" in tools
82+
assert "todo_TodoWrite" not in tools
8783

8884
def test_custom_server_name(self) -> None:
8985
"""Test creating proxy with custom name."""

tests/unit/utils/test_handlers_generator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def basic_tool() -> Tool:
2121
return Tool(
2222
name="test_tool",
2323
description="Test tool description",
24-
input_schema={"type": "object", "properties": {}},
24+
inputSchema={"type": "object", "properties": {}},
2525
)
2626

2727

@@ -31,7 +31,7 @@ def tool_with_params() -> Tool:
3131
return Tool(
3232
name="create_item",
3333
description="Create a new item",
34-
input_schema={
34+
inputSchema={
3535
"type": "object",
3636
"properties": {"name": {"type": "string"}, "quantity": {"type": "integer"}},
3737
"required": ["name"],
@@ -45,7 +45,7 @@ def tool_with_enum() -> Tool:
4545
return Tool(
4646
name="status_tool",
4747
description="Tool with status enum",
48-
input_schema={
48+
inputSchema={
4949
"type": "object",
5050
"properties": {"status": {"type": "string", "enum": ["active", "inactive"]}},
5151
"required": ["status"],
@@ -58,7 +58,7 @@ def tool_with_boolean() -> Tool:
5858
"""Create a Tool with boolean parameter."""
5959
return Tool(
6060
name="flag_tool",
61-
input_schema={
61+
inputSchema={
6262
"type": "object",
6363
"properties": {"enabled": {"type": "boolean"}},
6464
"required": [],
@@ -69,15 +69,15 @@ def tool_with_boolean() -> Tool:
6969
@pytest.fixture
7070
def empty_tool() -> Tool:
7171
"""Create a Tool without parameters."""
72-
return Tool(name="empty_tool", input_schema={"type": "object", "properties": {}})
72+
return Tool(name="empty_tool", inputSchema={"type": "object", "properties": {}})
7373

7474

7575
@pytest.fixture
7676
def tool_with_literal() -> Tool:
7777
"""Create a Tool with Literal type enum."""
7878
return Tool(
7979
name="tool_with_literal",
80-
input_schema={
80+
inputSchema={
8181
"type": "object",
8282
"properties": {"choice": {"type": "string", "enum": ["a", "b", "c"]}},
8383
},
@@ -222,7 +222,7 @@ async def test_generate_stub_to_file(self, tmp_path: Any, empty_tool: Tool) -> N
222222
config_file.write_text(json.dumps(config_data))
223223

224224
# Rename the tool for this test
225-
test_tool = Tool(name="my_tool", input_schema=empty_tool.input_schema)
225+
test_tool = Tool(name="my_tool", inputSchema=empty_tool.inputSchema)
226226

227227
# Mock Client
228228
mock_mcp = AsyncMock()

tests/utils/fastagent_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _serialize_tool_results(tool_results: dict[str, CallToolResult] | None) -> d
156156
serialized = {}
157157
for tool_id, result in tool_results.items():
158158
result_content = [MessageSerializer._serialize_content_item(c) for c in result.content]
159-
serialized[tool_id] = {"content": result_content, "is_error": result.is_error}
159+
serialized[tool_id] = {"content": result_content, "is_error": result.isError}
160160
return serialized
161161

162162
@staticmethod

tests/utils/test_fastagent_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_preserves_tool_calls(self) -> None:
5151
def test_preserves_tool_results(self) -> None:
5252
"""Test that tool results are preserved in serialization."""
5353
# Create a message with tool results
54-
tool_result = CallToolResult(content=[TextContent(type="text", text="Tool output")], is_error=False)
54+
tool_result = CallToolResult(content=[TextContent(type="text", text="Tool output")], isError=False)
5555

5656
msg = PromptMessageExtended(role="user", content=[], tool_results={"tool_123": tool_result})
5757

0 commit comments

Comments
 (0)