@@ -71,7 +71,21 @@ def test_tool_generation_basic(sample_app):
71
71
assert hasattr (tool , "parameters" ), "Tool missing 'parameters' property"
72
72
assert hasattr (tool , "fn_metadata" ), "Tool missing 'fn_metadata' property"
73
73
74
- # Verify specific properties of the list_items tool
74
+ # Skip MCP's internal tool that doesn't follow the same patterns
75
+ if tool .name == "handle_mcp_connection_mcp_get" :
76
+ continue
77
+
78
+ # With describe_all_responses=False by default, description should only include success response code
79
+ assert "200" in tool .description , f"Expected success response code in description for { tool .name } "
80
+ assert "422" not in tool .description , f"Expected not to see 422 response in tool description for { tool .name } "
81
+
82
+ # With describe_full_response_schema=False by default, description should not include the full output schema, only an example
83
+ assert "Example Response" in tool .description , f"Expected example response in description for { tool .name } "
84
+ assert "Output Schema" not in tool .description , (
85
+ f"Expected not to see output schema in description for { tool .name } "
86
+ )
87
+
88
+ # Verify specific parameters are present in the appropriate tools
75
89
list_items_tool = next ((t for t in tools if t .name == "list_items_items__get" ), None )
76
90
assert list_items_tool is not None , "list_items tool not found"
77
91
assert "skip" in list_items_tool .parameters ["properties" ], "Expected 'skip' parameter"
@@ -88,17 +102,16 @@ def test_tool_generation_with_full_schema(sample_app):
88
102
# Extract tools for inspection
89
103
tools = mcp_server ._tool_manager .list_tools ()
90
104
91
- # Verify specific properties of the list_items tool
92
- list_items_tool = next ((t for t in tools if t .name == "list_items_items__get" ), None )
93
- assert list_items_tool is not None , "list_items tool not found"
94
-
95
- # In the full schema mode, the item schema should be included somewhere in the tool
96
- # This might be in the description rather than the parameters
97
- description = list_items_tool .description
105
+ # Check all tools have the appropriate schema information
106
+ for tool in tools :
107
+ # Skip MCP's internal tool that doesn't follow the same patterns
108
+ if tool .name == "handle_mcp_connection_mcp_get" :
109
+ continue
98
110
99
- # Check that the tool includes information about the Item schema
100
- assert "Item" in description , "Item schema should be included in the description"
101
- assert "price" in description , "Item properties should be included in the description"
111
+ description = tool .description
112
+ # Check that the tool includes information about the Item schema
113
+ assert "Item" in description , f"Item schema should be included in the description for { tool .name } "
114
+ assert "price" in description , f"Item properties should be included in the description for { tool .name } "
102
115
103
116
104
117
def test_tool_generation_with_all_responses (sample_app ):
@@ -111,12 +124,39 @@ def test_tool_generation_with_all_responses(sample_app):
111
124
# Extract tools for inspection
112
125
tools = mcp_server ._tool_manager .list_tools ()
113
126
114
- # Find the read_item tool
115
- read_item_tool = next ((t for t in tools if t .name == "read_item_items__item_id__get" ), None )
116
- assert read_item_tool is not None , "read_item tool not found"
127
+ # Check all API tools include all response status codes
128
+ for tool in tools :
129
+ # Skip MCP's internal tool that doesn't follow the same patterns
130
+ if tool .name == "handle_mcp_connection_mcp_get" :
131
+ continue
132
+
133
+ assert "200" in tool .description , f"Expected success response code in description for { tool .name } "
134
+ assert "422" in tool .description , f"Expected 422 response code in description for { tool .name } "
135
+
136
+
137
+ def test_tool_generation_with_all_responses_and_full_schema (sample_app ):
138
+ """Test that MCP tools include all possible responses and full schema when requested."""
139
+ # Create MCP server with all response status codes and full schema
140
+ mcp_server = add_mcp_server (
141
+ sample_app ,
142
+ serve_tools = True ,
143
+ base_url = "http://localhost:8000" ,
144
+ describe_all_responses = True ,
145
+ describe_full_response_schema = True ,
146
+ )
147
+
148
+ # Extract tools for inspection
149
+ tools = mcp_server ._tool_manager .list_tools ()
150
+
151
+ # Check all tools include all response status codes and the full output schema
152
+ for tool in tools :
153
+ # Skip MCP's internal tool that doesn't follow the same patterns
154
+ if tool .name == "handle_mcp_connection_mcp_get" :
155
+ continue
117
156
118
- # With describe_all_responses=True, description should include response status codes
119
- assert "200" in read_item_tool .description , "Expected success response code in description"
157
+ assert "200" in tool .description , f"Expected success response code in description for { tool .name } "
158
+ assert "422" in tool .description , f"Expected 422 response code in description for { tool .name } "
159
+ assert "Output Schema" in tool .description , f"Expected output schema in description for { tool .name } "
120
160
121
161
122
162
def test_custom_tool_addition (sample_app ):
0 commit comments