Skip to content

Commit 7c0b1f9

Browse files
committed
Rename module: responses -> results
1 parent 2a76d1b commit 7c0b1f9

6 files changed

Lines changed: 32 additions & 4 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,34 @@ npx @modelcontextprotocol/inspector
129129

130130
7. Navigate to the MCP Inspector webpage and connect to `http://127.0.0.1:8063` (no `/mcp`) using `Streamable HTTP` transport type
131131

132+
## Tool return values
133+
134+
Using the `python-sdk` cannonical way of building results (this is, the `CallToolResult` object) can get quite verbose quite fast. For
135+
that reason, the `mcp_server` provides an optional set of functions to use.
136+
137+
The two following tools and return values are possible:
138+
139+
```python
140+
@registry.tool()
141+
def hello_world() -> DataToolOutput:
142+
"""Return a hello world value. """
143+
source = "https://example.org/link/to/data"
144+
return CallToolResult(
145+
content=[TextContent(type="text", text="Hello world!!")],
146+
structuredContent={"sources": [source]},
147+
)
148+
```
149+
150+
```python
151+
from mcp_server.results import text_result
152+
153+
@registry.tool()
154+
def hello_world() -> DataToolOutput:
155+
"""Return a hello world value. """
156+
source = "https://example.org/link/to/data"
157+
return text_result("Hello world!!", source=source)
158+
```
159+
132160
## DataToolOutput
133161

134162
This MCP Server uses a `DataToolOutput` annotation and a `ValidationModel` to enforce a standardized contract between plugins and the server. The schema is still in development so changes are expected.

src/mcp_server/engines/aggregate_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
from mcp_server import DataToolOutput
4747
from mcp_server.engines.filters import build_filter_params, apply_filters, build_filter_doc
48-
from mcp_server.responses import text_result, force_result
48+
from mcp_server.results import text_result, force_result
4949

5050

5151
AGGREGATIONS = {

src/mcp_server/engines/row_list_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import pandas as pd
5656
from mcp_server import DataToolOutput
5757
from mcp_server.engines.filters import build_filter_params, apply_filters, build_filter_doc
58-
from mcp_server.responses import text_result, force_result
58+
from mcp_server.results import text_result, force_result
5959

6060

6161
def load_row_list_dataset(mcp, config, yaml_path):

src/mcp_server/engines/top_row_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
from mcp_server import DataToolOutput
5858
from mcp_server.engines.filters import build_filter_params, apply_filters, build_filter_doc
59-
from mcp_server.responses import text_result, force_result
59+
from mcp_server.results import text_result, force_result
6060

6161

6262
def load_top_row_dataset(mcp, config, yaml_path):

src/mcp_server/engines/unique_values_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
from mcp_server import DataToolOutput
4343
from mcp_server.engines.filters import build_filter_params, apply_filters, build_filter_doc
44-
from mcp_server.responses import text_result
44+
from mcp_server.results import text_result
4545

4646

4747
def load_unique_values_dataset(mcp, config, yaml_path):

0 commit comments

Comments
 (0)