Support MCP in packaged Python runtime

This commit is contained in:
fz
2026-08-18 13:50:53 +08:00
parent 85e821b926
commit 94f6fd1306
13 changed files with 253 additions and 6 deletions
+41
View File
@@ -30,3 +30,44 @@ def test_child_prompt_precedes_runtime_context(prompt_name: str, expected: str)
for chunk in chunks
for choice in chunk.get("choices", [])
)
def test_mcp_smoke_requests_the_discovered_tool() -> None:
chunks = SMOKE["completion_chunks"]({
"messages": [{"role": "user", "content": SMOKE["MCP_PROMPT"]}],
"tools": [{"type": "function", "function": {"name": "mcp__fixture__add"}}],
})
calls = [
call
for chunk in chunks
for choice in chunk.get("choices", [])
for call in choice.get("delta", {}).get("tool_calls", [])
]
assert calls[0]["function"] == {
"name": "mcp__fixture__add",
"arguments": '{"a": 19, "b": 23}',
}
def test_mcp_smoke_accepts_the_external_server_result() -> None:
chunks = SMOKE["completion_chunks"]({
"messages": [
{"role": "user", "content": SMOKE["MCP_PROMPT"]},
{
"role": "assistant",
"tool_calls": [{
"id": "mcp-add",
"type": "function",
"function": {"name": "mcp__fixture__add", "arguments": '{}'},
}],
},
{"role": "tool", "tool_call_id": "mcp-add", "content": "42"},
],
})
assert any(
choice.get("delta", {}).get("content") == SMOKE["MCP_TEXT"]
for chunk in chunks
for choice in chunk.get("choices", [])
)