sxhxliang / mcp-access-point

Turn a web server into an MCP server in one click without making any code changes.
https://deepwiki.com/OpenAgentX/mcp-access-point
MIT License
71 stars 15 forks source link

Post request not working correctly #6

Closed dhruv-bansal closed 3 days ago

dhruv-bansal commented 1 month ago

I am using given example of openapi_for_demo.json and try to call addPet tool

Image

The complete jsonRPC body is being passed to upstream which is causing an issue.

Logs of the upstream < Body: {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"_meta":{"progressToken":2},"name":"addPet","arguments":{"body":{"id":1,"name":"test1","tag":"test2"}}}}

sxhxliang commented 1 month ago

Fixed - all HTTP responses now return 200 OK. Give it another try!

BTW. The 422 error indicates that the request value is not the data expected by your API server.

sxhxliang commented 1 month ago

I also provide a FastAPI Petstore implementation

dhruv-bansal commented 1 month ago

Issue still persist. Same issue as stated above - The complete jsonRPC body is being passed to upstream which is causing an issue.

I don't see code anywhere to modify the body before sending the request to upstream.

sxhxliang commented 1 month ago

Can you try hitting the API endpoint directly to see what it returns? and provide some information about the client version, protocol type, API interface, etc.?

dhruv-bansal commented 1 week ago

There is no option to re-open the issue - can you unable it?

Also here is the pull request for the fix of this issue. - https://github.com/sxhxliang/mcp-access-point/pull/11

Here is how I am testing. Upstream I am using prism or actual request server Issue Issue in case of tool call for POST/PUT operation of HTTP, complete original JSON RPC method is being forwarded to upstream.

This PR handles that scenario.

Also, earlier upstream actual response code was ignored and only 200 was sent. That is also handled now.

sxhxliang commented 1 week ago

@dhruv-bansal Thank you for providing a PR. I will test it later.

  1. This will speed up my verification if you can provide some test cases, and you can modify the python code in the demo.
  2. Regarding the response status code, because MCP uses the jsonRPC protocol, I understand that it is not necessary to return the status code of the upstream service. The status code can be returned in the jsonRPC result. The official updated the protocol version on June 18. I am trying to understand the official protocol to see if there is a more reasonable way to deal with this problem. Welcome to discuss it.
sxhxliang commented 3 days ago

done!