Skip to content

Conversation

Yuan325
Copy link
Contributor

@Yuan325 Yuan325 commented Apr 4, 2025

Adding Toolbox support for MCP. Toolbox can now be run as an MCP server.

Fixes #312.

@Yuan325 Yuan325 requested a review from a team as a code owner April 4, 2025 17:39
Copy link
Contributor

github-actions bot commented Apr 4, 2025

@kurtisvg kurtisvg changed the title feat: adding Toolbox support for MCP feat: adding support for Model Context Protocol (MCP). Apr 4, 2025
Copy link
Contributor

github-actions bot commented Apr 4, 2025

Yuan325 and others added 11 commits April 4, 2025 12:14
Add http post endpoint for mcp at `api/mcp`. Types are based on the
2024-11-05
[specification](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts).

Tested with:
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0",
"id": 1, "method": "foo"}' http://127.0.0.1:5000/mcp`
Response:
`{"jsonrpc":"2.0","id":1,"result":{}}`

Test cases included.
Add support for the `initialize` phase for mcp's connection lifecycle.

After receiving the `initialize` request, the server will respond with
it's own capabilities and information. Since there are only one protocol
supported, we don't have to do protocol version comparison. Toolbox
server will response with the default protocol version.

Initial support for MCP Tools will not include list changed
notification.

Test cases included.
Parse existing toolbox manifest to ToolsList that is compatible with MCP
[tools
definition](https://modelcontextprotocol.io/docs/concepts/tools#tool-definition-structure).

AuthServices will be omitted since MCP doesn't support auth at this
time.

---------

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Add `tools/list` method. 

Example to call the `tools/list` method:
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0",
"id": 1, "method": "tools/list"}' http://127.0.0.1:5000/mcp`

Toolbox will response. with a valid JSONRPCResponse with a list of all
tools available.

---------

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Add `tools/call` method. 

Example to call the `tools/list` method:
`curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0",
"id": 1, "method": "tools/list", "params":{"name": "my-tool"}}'
http://127.0.0.1:5000/mcp`

Toolbox will response with a valid JSONRPCResponse of the result of tool
invocation.
Tested sse implementation with MCP
[inspector](https://modelcontextprotocol.io/docs/tools/inspector) tool.

---------

Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
forgot to add the `IsError` field previously.

Also added integration tests for that.
Add traces, metrics, and logs to mcp router.
variable `id` is used in metrics to record the session id.

`json.Number` will throw an error when casting to string with
`.(string)`.
added/updated the following docs:
1. Updated FaQ question about MCP.
2. Added a how-to `Connect with MCP`. This includes connecting to
Toolbox with MCP client via HTTP (sse) and HTTP (without SSE), or
inspector.
3. Added a quick start `MCP quickstart`. Step 1 and Step 2 of this
quickstart is the same as the other local quickstart.

---------

Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com>
Copy link
Contributor

github-actions bot commented Apr 4, 2025

@Yuan325 Yuan325 enabled auto-merge (squash) April 4, 2025 18:21
Copy link
Contributor

github-actions bot commented Apr 4, 2025

@Yuan325 Yuan325 merged commit a7d1d4e into main Apr 4, 2025
7 checks passed
@Yuan325 Yuan325 deleted the mcp branch April 4, 2025 18:24
Copy link
Contributor

github-actions bot commented Apr 4, 2025

🧨 Preview deployments removed.

github-actions bot pushed a commit that referenced this pull request Apr 4, 2025
Adding Toolbox support for MCP. Toolbox can now be run as an MCP server.

Fixes #312.

---------

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com> a7d1d4e
github-actions bot pushed a commit to renovate-bot/googleapis-_-genai-toolbox that referenced this pull request Apr 4, 2025
…eapis#396)

Adding Toolbox support for MCP. Toolbox can now be run as an MCP server.

Fixes googleapis#312.

---------

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com> a7d1d4e
Yuan325 pushed a commit that referenced this pull request Apr 4, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.3.0](v0.2.1...v0.3.0)
(2025-04-04)


### Features

* Add 'alloydb-ai-nl' tool
([#358](#358))
([f02885f](f02885f))
* Add HTTP Source and Tool
([#332](#332))
([64da5b4](64da5b4))
* Adding support for Model Context Protocol (MCP).
([#396](#396))
([a7d1d4e](a7d1d4e))
* Added [toolbox-core](https://pypi.org/project/toolbox-core/) SDK –
easily integrate Toolbox into any Python function calling framework


### Bug Fixes

* Add `tools-file` flag and deprecate `tools_file`
([#384](#384))
([34a7263](34a7263)),
closes [#383](#383)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Apr 4, 2025
🤖 I have created a release *beep* *boop*
---

##
[0.3.0](v0.2.1...v0.3.0)
(2025-04-04)

### Features

* Add 'alloydb-ai-nl' tool
([#358](#358))
([f02885f](f02885f))
* Add HTTP Source and Tool
([#332](#332))
([64da5b4](64da5b4))
* Adding support for Model Context Protocol (MCP).
([#396](#396))
([a7d1d4e](a7d1d4e))
* Added [toolbox-core](https://pypi.org/project/toolbox-core/) SDK –
easily integrate Toolbox into any Python function calling framework

### Bug Fixes

* Add `tools-file` flag and deprecate `tools_file`
([#384](#384))
([34a7263](34a7263)),
closes [#383](#383)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> 12222fe
github-actions bot pushed a commit to renovate-bot/googleapis-_-genai-toolbox that referenced this pull request Apr 4, 2025
🤖 I have created a release *beep* *boop*
---

##
[0.3.0](googleapis/genai-toolbox@v0.2.1...v0.3.0)
(2025-04-04)

### Features

* Add 'alloydb-ai-nl' tool
([googleapis#358](googleapis#358))
([f02885f](googleapis@f02885f))
* Add HTTP Source and Tool
([googleapis#332](googleapis#332))
([64da5b4](googleapis@64da5b4))
* Adding support for Model Context Protocol (MCP).
([googleapis#396](googleapis#396))
([a7d1d4e](googleapis@a7d1d4e))
* Added [toolbox-core](https://pypi.org/project/toolbox-core/) SDK –
easily integrate Toolbox into any Python function calling framework

### Bug Fixes

* Add `tools-file` flag and deprecate `tools_file`
([googleapis#384](googleapis#384))
([34a7263](googleapis@34a7263)),
closes [googleapis#383](googleapis#383)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> 12222fe
jeffreyrubi pushed a commit to jeffreyrubi/genai-toolbox that referenced this pull request Jun 7, 2025
…is#396)

# Description

Python 3.12 has deprecated the `utcnow()` method. Updated to use the
recommended `datetime.now(UTC)` approach instead.
jeffreyrubi pushed a commit to jeffreyrubi/genai-toolbox that referenced this pull request Jun 7, 2025
Adding Toolbox support for MCP. Toolbox can now be run as an MCP server.

Fixes googleapis#312.

---------

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Averi Kitsch <akitsch@google.com>
jeffreyrubi pushed a commit to jeffreyrubi/genai-toolbox that referenced this pull request Jun 7, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.3.0](googleapis/genai-toolbox@v0.2.1...v0.3.0)
(2025-04-04)


### Features

* Add 'alloydb-ai-nl' tool
([googleapis#358](googleapis#358))
([f02885f](googleapis@f02885f))
* Add HTTP Source and Tool
([googleapis#332](googleapis#332))
([64da5b4](googleapis@64da5b4))
* Adding support for Model Context Protocol (MCP).
([googleapis#396](googleapis#396))
([a7d1d4e](googleapis@a7d1d4e))
* Added [toolbox-core](https://pypi.org/project/toolbox-core/) SDK –
easily integrate Toolbox into any Python function calling framework


### Bug Fixes

* Add `tools-file` flag and deprecate `tools_file`
([googleapis#384](googleapis#384))
([34a7263](googleapis@34a7263)),
closes [googleapis#383](googleapis#383)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Model Context Protocol (MCP)
3 participants