-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
Observed the same behavior on two OpenAI-compatible Responses API backends:
- local LM Studio host
- Aliyun-hosted model service
On both backends, a simple local stdio MCP server such as calculator works on the same Agent Framework + MCPStdioTool + /v1/responses path, but the official matlab-mcp-core-server does not and fails before a real tool invocation completes.
This suggests the problem is narrower than "Responses API does not support local MCP" or "all local MCP servers fail". It appears to be specific to this class of MCP server.
Because Agent Framework implements local MCP by loading MCP tools and exposing them as normal tools/function calls, the current suspicion is that the incompatibility happens in that decomposition step: simpler MCP servers such as calculator still work, but matlab-mcp-core-server does not.
Code Sample
# Code Sample
## MATLAB ver.
import asyncio
import traceback
from pathlib import Path
from agent_framework import Agent, MCPStdioTool
from agent_framework.openai import OpenAIResponsesClient
BASE_URL = "http://127.0.0.1:1234/v1"
MODEL = "qwen/qwen3.5-9b"
PROMPT = "Please call detect_matlab_toolboxes and summarize the detected MATLAB version and toolbox names."
WORKING_DIR = Path("/Users/***/projects/skills-demo")
MATLAB_MCP_COMMAND = "/Users/***/Developer/mcp-servers/matlab-core/matlab-mcp-core-server"
MATLAB_ROOT = "/Applications/MATLAB_R2025b.app"
MATLAB_DISPLAY_MODE = "nodesktop"
ALLOWED_TOOLS = ["detect_matlab_toolboxes"]
async def main() -> int:
client = OpenAIResponsesClient(
model_id=MODEL,
base_url=BASE_URL,
api_key="lm-studio",
)
tool = MCPStdioTool(
name="matlab",
command=MATLAB_MCP_COMMAND,
args=[
f"--initial-working-folder={WORKING_DIR.resolve()}",
"--disable-telemetry=true",
f"--matlab-root={MATLAB_ROOT}",
f"--matlab-display-mode={MATLAB_DISPLAY_MODE}",
],
allowed_tools=ALLOWED_TOOLS or None,
request_timeout=120,
description="Official MATLAB MCP core server",
)
agent = Agent(
client=client,
instructions="Use the available tools when needed and answer the user request.",
tools=[tool],
)
try:
response = await agent.run(PROMPT)
except Exception as exc:
print(f"{type(exc).__name__}: {exc}")
traceback.print_exc()
return 1
print(response.text)
return 0
asyncio.run(main())
## Calculator ver.
Use the same structure as above, and replace only the MCP-specific constants, tool construction, and prompt:
- PROMPT = "Please call detect_matlab_toolboxes and summarize the detected MATLAB version and toolbox names."
- WORKING_DIR = Path("/Users/***/projects/skills-demo")
- MATLAB_MCP_COMMAND = "/Users/***/Developer/mcp-servers/matlab-core/matlab-mcp-core-server"
- MATLAB_ROOT = "/Applications/MATLAB_R2025b.app"
- MATLAB_DISPLAY_MODE = "nodesktop"
- ALLOWED_TOOLS = ["detect_matlab_toolboxes"]
+ PROMPT = "Please use the calculator tool to compute 17 * (5 + 3), and return only the final numeric result."
+ CALCULATOR_MCP_COMMAND = "uvx"
+ CALCULATOR_MCP_ARGS = ["mcp-server-calculator"]
+ ALLOWED_TOOLS = ["calculate"]
- tool = MCPStdioTool(
- name="matlab",
- command=MATLAB_MCP_COMMAND,
- args=[
- f"--initial-working-folder={WORKING_DIR.resolve()}",
- "--disable-telemetry=true",
- f"--matlab-root={MATLAB_ROOT}",
- f"--matlab-display-mode={MATLAB_DISPLAY_MODE}",
- ],
- allowed_tools=ALLOWED_TOOLS or None,
- request_timeout=120,
- description="Official MATLAB MCP core server",
- )
+ tool = MCPStdioTool(
+ name="calculator",
+ command=CALCULATOR_MCP_COMMAND,
+ args=CALCULATOR_MCP_ARGS,
+ allowed_tools=ALLOWED_TOOLS or None,
+ request_timeout=120,
+ description="Simple calculator MCP server",
+ )Error Messages / Stack Traces
## MATLAB Script
The main failure is a `400 invalid_request_error` returned from the OpenAI-compatible `Responses API` backend:
openai.BadRequestError: Error code: 400 - {
'error': {
'message': 'Invalid',
'type': 'invalid_request_error',
'param': 'tools.0.type',
'code': 'invalid_string'
}
}
Agent Framework then surfaces that as:
agent_framework.exceptions.ChatClientException:
<class 'agent_framework.openai._responses_client.OpenAIResponsesClient'>
service failed to complete the prompt:
Error code: 400 - {
'error': {
'message': 'Invalid',
'type': 'invalid_request_error',
'param': 'tools.0.type',
'code': 'invalid_string'
}
}
Minimal traceback:
File ".../mcp-test/repro_matlab_mcp.py", line 46, in main
response = await agent.run(PROMPT)
File ".../site-packages/agent_framework/_agents.py", line 838, in _run_non_streaming
response = await self.client.get_response(...)
File ".../site-packages/agent_framework/_tools.py", line 2139, in _get_response
response = await super_get_response(...)
File ".../site-packages/agent_framework/openai/_responses_client.py", line 341, in _get_response
self._handle_request_error(ex)
File ".../site-packages/agent_framework/openai/_responses_client.py", line 266, in _handle_request_error
raise ChatClientException(...)
## Cleanup-time error
After the main MATLAB failure, there is also a separate cleanup-time exception from the stdio client:
RuntimeError: Attempted to exit cancel scope in a different task than it was entered in
This same cleanup issue can also appear after successful MCP runs, so it does not appear to be the primary cause of the MATLAB incompatibility.Package Versions
agent-framework-core 1.0.0rc2, openai 2.24.0, mcp 1.26.0, anyio 4.12.1
Python Version
Python 3.13
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status