Skip to content

Commit f44c3af

Browse files
tool executer api for external mcp server (#1816)
* tool executer api for external mcp server * deepsource fix * deepsource fix * remove promql tool, remove confirmed from tool call request, coderabbit comment fix
1 parent 322e03c commit f44c3af

5 files changed

Lines changed: 1412 additions & 46 deletions

File tree

‎docs/tool-api.md‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Parseable tool REST API
2+
3+
Parseable owns the canonical tool catalog and execution semantics. External MCP
4+
servers adapt these REST endpoints to MCP `tools/list` and `tools/call`.
5+
6+
Both endpoints require normal Parseable authentication. Tool execution also
7+
applies the RBAC action required by the selected tool and any referenced
8+
dataset or resource.
9+
10+
## List tools
11+
12+
```http
13+
GET /api/prism/v1/llm/tools/list
14+
```
15+
16+
Response:
17+
18+
```json
19+
{
20+
"tools": [
21+
{
22+
"name": "get_dataset_schema",
23+
"title": "Get dataset schema",
24+
"description": "Get columns and data types for a dataset.",
25+
"inputSchema": {
26+
"type": "object",
27+
"properties": { "dataset": { "type": "string", "minLength": 1 } },
28+
"required": ["dataset"],
29+
"additionalProperties": false
30+
}
31+
}
32+
]
33+
}
34+
```
35+
36+
The response includes an `ETag` and
37+
`Cache-Control: private, max-age=300, must-revalidate`. A request with a
38+
matching `If-None-Match` receives `304 Not Modified`.
39+
40+
The catalog is edition-specific:
41+
42+
- OSS returns OSS-supported tools.
43+
- Enterprise returns OSS tools plus Enterprise tools.
44+
- Parseable Cloud uses the Enterprise server catalog and exposes the tools
45+
enabled by that deployment.
46+
47+
## Call a tool
48+
49+
```http
50+
POST /api/prism/v1/llm/tools/call
51+
Content-Type: application/json
52+
```
53+
54+
Request:
55+
56+
```json
57+
{
58+
"name": "get_dataset_schema",
59+
"arguments": { "dataset": "application-logs" }
60+
}
61+
```
62+
63+
`arguments` must satisfy the tool's `inputSchema`. For mutation and
64+
external-side-effect tools, the MCP host or another trusted caller is
65+
responsible for applying its confirmation policy before calling this endpoint.
66+
67+
Successful and failed executions use the MCP `CallToolResult` shape:
68+
69+
```json
70+
{
71+
"content": [
72+
{ "type": "text", "text": "{\"fields\":[...]}" }
73+
],
74+
"structuredContent": {
75+
"result": { "fields": [] }
76+
},
77+
"isError": false
78+
}
79+
```
80+
81+
Tool failures set `isError` to `true`, include a text error content item, and
82+
put the message under `structuredContent.error.message`. A completed tool call
83+
returns HTTP 200 even when the tool reports `isError: true`, matching MCP
84+
`tools/call` semantics. REST status codes distinguish failures that prevent a
85+
call from starting, such as malformed input, authentication, or an unknown
86+
tool.
87+
88+
The REST API is not itself an MCP transport. An MCP adapter maps the registry
89+
response to `tools/list`, forwards calls to this endpoint, and returns the
90+
`CallToolResult` from Parseable through MCP `tools/call`.

‎src/handlers/http/modal/server.rs‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,18 @@ impl ParseableServer for Server {
201201

202202
impl Server {
203203
pub fn get_llm_webscope() -> Scope {
204-
web::scope("/llm").service(
205-
web::resource("/tools").route(
206-
web::get()
207-
.to(crate::tool_catalog::list_tool_registry)
208-
.authorize(Action::Query),
209-
),
210-
)
204+
web::scope("/llm")
205+
.service(
206+
web::resource("/tools/list").route(
207+
web::get()
208+
.to(crate::tool_catalog::list_tool_registry)
209+
.authorize(Action::Query),
210+
),
211+
)
212+
.service(
213+
web::resource("/tools/call")
214+
.route(web::post().to(crate::tool_executor::call_tool_registry)),
215+
)
211216
}
212217

213218
pub fn get_prism_home() -> Scope {

‎src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub mod sync;
5858
pub mod telemetry;
5959
pub mod tenants;
6060
pub mod tool_catalog;
61+
pub mod tool_executor;
6162
pub mod users;
6263
pub mod utils;
6364
pub mod validator;

0 commit comments

Comments
 (0)