Skip to content

Commit e649acd

Browse files
committed
refactor: use snake case instead of camel case in types
1 parent 2b03860 commit e649acd

File tree

27 files changed

+84
-84
lines changed

27 files changed

+84
-84
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def validated_tool() -> Annotated[CallToolResult, ValidationModel]:
442442
"""Return CallToolResult with structured output validation."""
443443
return CallToolResult(
444444
content=[TextContent(type="text", text="Validated response")],
445-
structuredContent={"status": "success", "data": {"result": 42}},
445+
structured_content={"status": "success", "data": {"result": 42}},
446446
_meta={"internal": "metadata"},
447447
)
448448

@@ -757,8 +757,8 @@ async def run():
757757
# List available resource templates
758758
templates = await session.list_resource_templates()
759759
print("Available resource templates:")
760-
for template in templates.resourceTemplates:
761-
print(f" - {template.uriTemplate}")
760+
for template in templates.resource_templates:
761+
print(f" - {template.uri_template}")
762762

763763
# List available prompts
764764
prompts = await session.list_prompts()
@@ -767,20 +767,20 @@ async def run():
767767
print(f" - {prompt.name}")
768768

769769
# Complete resource template arguments
770-
if templates.resourceTemplates:
771-
template = templates.resourceTemplates[0]
772-
print(f"\nCompleting arguments for resource template: {template.uriTemplate}")
770+
if templates.resource_templates:
771+
template = templates.resource_templates[0]
772+
print(f"\nCompleting arguments for resource template: {template.uri_template}")
773773

774774
# Complete without context
775775
result = await session.complete(
776-
ref=ResourceTemplateReference(type="ref/resource", uri=template.uriTemplate),
776+
ref=ResourceTemplateReference(type="ref/resource", uri=template.uri_template),
777777
argument={"name": "owner", "value": "model"},
778778
)
779779
print(f"Completions for 'owner' starting with 'model': {result.completion.values}")
780780

781781
# Complete with context - repo suggestions based on owner
782782
result = await session.complete(
783-
ref=ResourceTemplateReference(type="ref/resource", uri=template.uriTemplate),
783+
ref=ResourceTemplateReference(type="ref/resource", uri=template.uri_template),
784784
argument={"name": "repo", "value": ""},
785785
context_arguments={"owner": "modelcontextprotocol"},
786786
)
@@ -910,7 +910,7 @@ async def connect_service(service_name: str, ctx: Context[ServerSession, None])
910910
mode="url",
911911
message=f"Authorization required to connect to {service_name}",
912912
url=f"https://{service_name}.example.com/oauth/authorize?elicit={elicitation_id}",
913-
elicitationId=elicitation_id,
913+
elicitation_id=elicitation_id,
914914
)
915915
]
916916
)
@@ -1706,7 +1706,7 @@ async def handle_list_tools() -> list[types.Tool]:
17061706
types.Tool(
17071707
name="query_db",
17081708
description="Query the database",
1709-
inputSchema={
1709+
input_schema={
17101710
"type": "object",
17111711
"properties": {"query": {"type": "string", "description": "SQL query to execute"}},
17121712
"required": ["query"],
@@ -1867,12 +1867,12 @@ async def list_tools() -> list[types.Tool]:
18671867
types.Tool(
18681868
name="get_weather",
18691869
description="Get current weather for a city",
1870-
inputSchema={
1870+
input_schema={
18711871
"type": "object",
18721872
"properties": {"city": {"type": "string", "description": "City name"}},
18731873
"required": ["city"],
18741874
},
1875-
outputSchema={
1875+
output_schema={
18761876
"type": "object",
18771877
"properties": {
18781878
"temperature": {"type": "number", "description": "Temperature in Celsius"},
@@ -1970,7 +1970,7 @@ async def list_tools() -> list[types.Tool]:
19701970
types.Tool(
19711971
name="advanced_tool",
19721972
description="Tool with full control including _meta field",
1973-
inputSchema={
1973+
input_schema={
19741974
"type": "object",
19751975
"properties": {"message": {"type": "string"}},
19761976
"required": ["message"],
@@ -1986,7 +1986,7 @@ async def handle_call_tool(name: str, arguments: dict[str, Any]) -> types.CallTo
19861986
message = str(arguments.get("message", ""))
19871987
return types.CallToolResult(
19881988
content=[types.TextContent(type="text", text=f"Processed: {message}")],
1989-
structuredContent={"result": "success", "message": message},
1989+
structured_content={"result": "success", "message": message},
19901990
_meta={"hidden": "data for client applications only"},
19911991
)
19921992

@@ -2062,7 +2062,7 @@ async def list_resources_paginated(request: types.ListResourcesRequest) -> types
20622062
# Determine next cursor
20632063
next_cursor = str(end) if end < len(ITEMS) else None
20642064

2065-
return types.ListResourcesResult(resources=page_items, nextCursor=next_cursor)
2065+
return types.ListResourcesResult(resources=page_items, next_cursor=next_cursor)
20662066
```
20672067

20682068
_Full example: [examples/snippets/servers/pagination_example.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/pagination_example.py)_
@@ -2103,8 +2103,8 @@ async def list_all_resources() -> None:
21032103
print(f"Fetched {len(result.resources)} resources")
21042104

21052105
# Check if there are more pages
2106-
if result.nextCursor:
2107-
cursor = result.nextCursor
2106+
if result.next_cursor:
2107+
cursor = result.next_cursor
21082108
else:
21092109
break
21102110

@@ -2167,7 +2167,7 @@ async def handle_sampling_message(
21672167
text="Hello, world! from model",
21682168
),
21692169
model="gpt-3.5-turbo",
2170-
stopReason="endTurn",
2170+
stop_reason="endTurn",
21712171
)
21722172

21732173

@@ -2205,7 +2205,7 @@ async def run():
22052205
result_unstructured = result.content[0]
22062206
if isinstance(result_unstructured, types.TextContent):
22072207
print(f"Tool result: {result_unstructured.text}")
2208-
result_structured = result.structuredContent
2208+
result_structured = result.structured_content
22092209
print(f"Structured tool result: {result_structured}")
22102210

22112211

@@ -2306,7 +2306,7 @@ async def display_resources(session: ClientSession):
23062306
print(f"Resource: {display_name} ({resource.uri})")
23072307

23082308
templates_response = await session.list_resource_templates()
2309-
for template in templates_response.resourceTemplates:
2309+
for template in templates_response.resource_templates:
23102310
display_name = get_display_name(template)
23112311
print(f"Resource Template: {display_name}")
23122312

examples/fastmcp/direct_call_tool_result_return.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ class EchoResponse(BaseModel):
2020
def echo(text: str) -> Annotated[CallToolResult, EchoResponse]:
2121
"""Echo the input text with structure and metadata"""
2222
return CallToolResult(
23-
content=[TextContent(type="text", text=text)], structuredContent={"text": text}, _meta={"some": "metadata"}
23+
content=[TextContent(type="text", text=text)], structured_content={"text": text}, _meta={"some": "metadata"}
2424
)

examples/servers/simple-pagination/mcp_simple_pagination/server.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
name=f"tool_{i}",
2020
title=f"Tool {i}",
2121
description=f"This is sample tool number {i}",
22-
inputSchema={"type": "object", "properties": {"input": {"type": "string"}}},
22+
input_schema={"type": "object", "properties": {"input": {"type": "string"}}},
2323
)
2424
for i in range(1, 26) # 25 tools total
2525
]
@@ -71,7 +71,7 @@ async def list_tools_paginated(request: types.ListToolsRequest) -> types.ListToo
7171
start_idx = int(cursor)
7272
except (ValueError, TypeError):
7373
# Invalid cursor, return empty
74-
return types.ListToolsResult(tools=[], nextCursor=None)
74+
return types.ListToolsResult(tools=[], next_cursor=None)
7575

7676
# Get the page of tools
7777
page_tools = SAMPLE_TOOLS[start_idx : start_idx + page_size]
@@ -81,7 +81,7 @@ async def list_tools_paginated(request: types.ListToolsRequest) -> types.ListToo
8181
if start_idx + page_size < len(SAMPLE_TOOLS):
8282
next_cursor = str(start_idx + page_size)
8383

84-
return types.ListToolsResult(tools=page_tools, nextCursor=next_cursor)
84+
return types.ListToolsResult(tools=page_tools, next_cursor=next_cursor)
8585

8686
# Paginated list_resources - returns 10 resources per page
8787
@app.list_resources()
@@ -100,7 +100,7 @@ async def list_resources_paginated(
100100
start_idx = int(cursor)
101101
except (ValueError, TypeError):
102102
# Invalid cursor, return empty
103-
return types.ListResourcesResult(resources=[], nextCursor=None)
103+
return types.ListResourcesResult(resources=[], next_cursor=None)
104104

105105
# Get the page of resources
106106
page_resources = SAMPLE_RESOURCES[start_idx : start_idx + page_size]
@@ -110,7 +110,7 @@ async def list_resources_paginated(
110110
if start_idx + page_size < len(SAMPLE_RESOURCES):
111111
next_cursor = str(start_idx + page_size)
112112

113-
return types.ListResourcesResult(resources=page_resources, nextCursor=next_cursor)
113+
return types.ListResourcesResult(resources=page_resources, next_cursor=next_cursor)
114114

115115
# Paginated list_prompts - returns 7 prompts per page
116116
@app.list_prompts()
@@ -129,7 +129,7 @@ async def list_prompts_paginated(
129129
start_idx = int(cursor)
130130
except (ValueError, TypeError):
131131
# Invalid cursor, return empty
132-
return types.ListPromptsResult(prompts=[], nextCursor=None)
132+
return types.ListPromptsResult(prompts=[], next_cursor=None)
133133

134134
# Get the page of prompts
135135
page_prompts = SAMPLE_PROMPTS[start_idx : start_idx + page_size]
@@ -139,7 +139,7 @@ async def list_prompts_paginated(
139139
if start_idx + page_size < len(SAMPLE_PROMPTS):
140140
next_cursor = str(start_idx + page_size)
141141

142-
return types.ListPromptsResult(prompts=page_prompts, nextCursor=next_cursor)
142+
return types.ListPromptsResult(prompts=page_prompts, next_cursor=next_cursor)
143143

144144
# Implement call_tool handler
145145
@app.call_tool()

examples/servers/simple-streamablehttp-stateless/mcp_simple_streamablehttp_stateless/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def list_tools() -> list[types.Tool]:
7373
types.Tool(
7474
name="start-notification-stream",
7575
description=("Sends a stream of notifications with configurable count and interval"),
76-
inputSchema={
76+
input_schema={
7777
"type": "object",
7878
"required": ["interval", "count", "caller"],
7979
"properties": {

examples/servers/simple-streamablehttp/mcp_simple_streamablehttp/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async def list_tools() -> list[types.Tool]:
8787
types.Tool(
8888
name="start-notification-stream",
8989
description=("Sends a stream of notifications with configurable count and interval"),
90-
inputSchema={
90+
input_schema={
9191
"type": "object",
9292
"required": ["interval", "count", "caller"],
9393
"properties": {

examples/servers/simple-task-interactive/mcp_simple_task_interactive/server.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ async def list_tools() -> list[types.Tool]:
3131
types.Tool(
3232
name="confirm_delete",
3333
description="Asks for confirmation before deleting (demonstrates elicitation)",
34-
inputSchema={
34+
input_schema={
3535
"type": "object",
3636
"properties": {"filename": {"type": "string"}},
3737
},
38-
execution=types.ToolExecution(taskSupport=types.TASK_REQUIRED),
38+
execution=types.ToolExecution(task_support=types.TASK_REQUIRED),
3939
),
4040
types.Tool(
4141
name="write_haiku",
4242
description="Asks LLM to write a haiku (demonstrates sampling)",
43-
inputSchema={"type": "object", "properties": {"topic": {"type": "string"}}},
44-
execution=types.ToolExecution(taskSupport=types.TASK_REQUIRED),
43+
input_schema={"type": "object", "properties": {"topic": {"type": "string"}}},
44+
execution=types.ToolExecution(task_support=types.TASK_REQUIRED),
4545
),
4646
]
4747

@@ -59,7 +59,7 @@ async def work(task: ServerTaskContext) -> types.CallToolResult:
5959

6060
result = await task.elicit(
6161
message=f"Are you sure you want to delete '{filename}'?",
62-
requestedSchema={
62+
requested_schema={
6363
"type": "object",
6464
"properties": {"confirm": {"type": "boolean"}},
6565
"required": ["confirm"],
@@ -121,7 +121,7 @@ async def handle_call_tool(name: str, arguments: dict[str, Any]) -> types.CallTo
121121
else:
122122
return types.CallToolResult(
123123
content=[types.TextContent(type="text", text=f"Unknown tool: {name}")],
124-
isError=True,
124+
is_error=True,
125125
)
126126

127127

examples/servers/simple-task/mcp_simple_task/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ async def list_tools() -> list[types.Tool]:
2626
types.Tool(
2727
name="long_running_task",
2828
description="A task that takes a few seconds to complete with status updates",
29-
inputSchema={"type": "object", "properties": {}},
30-
execution=types.ToolExecution(taskSupport=types.TASK_REQUIRED),
29+
input_schema={"type": "object", "properties": {}},
30+
execution=types.ToolExecution(task_support=types.TASK_REQUIRED),
3131
)
3232
]
3333

@@ -60,7 +60,7 @@ async def handle_call_tool(name: str, arguments: dict[str, Any]) -> types.CallTo
6060
else:
6161
return types.CallToolResult(
6262
content=[types.TextContent(type="text", text=f"Unknown tool: {name}")],
63-
isError=True,
63+
is_error=True,
6464
)
6565

6666

examples/servers/simple-tool/mcp_simple_tool/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def list_tools() -> list[types.Tool]:
4444
name="fetch",
4545
title="Website Fetcher",
4646
description="Fetches a website and returns its content",
47-
inputSchema={
47+
input_schema={
4848
"type": "object",
4949
"required": ["url"],
5050
"properties": {

examples/servers/sse-polling-demo/mcp_sse_polling_demo/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async def list_tools() -> list[types.Tool]:
120120
"Process a batch of items with periodic checkpoints. "
121121
"Demonstrates SSE polling where server closes stream periodically."
122122
),
123-
inputSchema={
123+
input_schema={
124124
"type": "object",
125125
"properties": {
126126
"items": {

examples/servers/structured-output-lowlevel/mcp_structured_output_lowlevel/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ async def list_tools() -> list[types.Tool]:
2727
types.Tool(
2828
name="get_weather",
2929
description="Get weather information (simulated)",
30-
inputSchema={
30+
input_schema={
3131
"type": "object",
3232
"properties": {"city": {"type": "string", "description": "City name"}},
3333
"required": ["city"],
3434
},
35-
outputSchema={
35+
output_schema={
3636
"type": "object",
3737
"properties": {
3838
"temperature": {"type": "number"},

0 commit comments

Comments
 (0)