Expose (to Client
) and Subscribe (at Server
) on call tool
event without a real C# method at Server
#301
IvanMurzak
started this conversation in
Ideas
Replies: 1 comment
-
@stephentoub thanks for moving to discussing. That is a good idea! Anyway, would you like if I make a separated issue for the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
I am working on Unity-MCP project. Unity Engine is a dedicated app which doesn't have exposed API for external access. The only one way to connect MCP server with Unity is to create a
Plugin
and integrate it into Unity. Then, via TCP connection with MCPServer
they can talk to each other. The code which is responsible for takingresources
or running atool
should be in Unity as part of thePlugin
. Unfortunately because of the currentcsharp-sdk
limitation, a function for atool
should also be duplicated in the MCP server, and then connected with the same function inPlugin
. Which forces to produce code duplication and unnecessary complexity in communication between apps.Also,
Plugin
(package) is a read-only subject in Unity. Which doesn't let people to add customtools
in their projects. Unity Engine is designed to recompile Domain each time as only any C# file is changed. And the source code of the game is often used as "tools" for game development in Unity Editor. Which makes a lot of sense to expose the ability for developers to let them to add customtools
outside of read-only package.csharp-sdk
had an API for dynamic add of amethod
, but that should be a realmethod
with arguments in C# code. Which doesn't help to avoid code duplication. And doesn't let to add 'tools' outside of read-only area in a Unity project.Describe the solution you'd like
Yes, there is a solution which I already implemented and tested in Unity-MCP. Would be awesome to have it in
csharp-sdk
. It has some mind-shift in comparison to what I heard in talks at the repository. So please be patient in reading the explanation. Because that is truly seamless and intuitive way for people who would like to integrate MCP into a third-party app, or even natively into their own app or game.Let's determine few entities...
Client
- such a chat for a userServer
- (in this case) it is data transmitter between Client and PluginPlugin
- it istool
executor,resource
loader,tools list
provider,prompt
provider to theServer
Target
- Unity Editor, a game, any software such as Blender, Photoshop, 3DS Max etc.The
Plugin
is the core in this concept.Server
is only a data router and connector.Plugin's
responsibilities:Server
Server
about internal events if neededServer
if connection lostServer's
responsibilities:Plugin
capabilities (tools, resources, prompts) and updates toClient
Client
requests toPlugin
Plugin
capabilities provide it's own capabilities (needed for the specific category of tools, for example when theTarget
andPlugin
should be restarted by a command fromClient
.Plugin
if connection lostIdeal solution 💖
csharp-sdk
may support "Plugin" mode. It is similar to existedcsharp-sdk
architecture which supportsClient
andServer
modes, that is anotherPlugin
mode. It would require to have TCP connection betweenServer
andPlugin
.Plugin
mode supports the same style of method binding likecsharp-sdk
works for a Server already with attributes.Plugin
automatically shares and updates current capabilities withServer
via TCP connection.Plugin
is independent fromServer
and may life without connection. There is nothing to do with that, it just waits for connection withServer
By the way, I already implemented it all in Unity-MCP. Thinking about making a NuGet package from it. Any feedback is appreciated. Also, I understand that the
Plugin
concept is a bit out of the scope for thecsharp-sdk
for MCP. That is why I have the Minimal solution, which is really required such as a last jigsaw in the puzzle.Minimal solution ⭐
Server
mode and providing response to aClient
.tool
without a real C# method. Using JsonSchema for describing input arguments and result value is ideal.That is it, only two things in the minimal solution. Both of them already exist in the project, just need to connect them together.
Minimal solution 2 ⭐⭐⭐
IMcpServer.NotifyTooListChanged
method. It would request list of tools using the handler that were added earlier using.WithListToolsHandler
.It feels like the Minimal solution 2 is even simpler for both group of developers:
csharp-sdk
developers and MCP server developers. We (MCP server devs) don't need to worry about about managing thetools
reactive collection. The list of tools already exposed using the handler. There is not much sense for doing that in two places.Beta Was this translation helpful? Give feedback.
All reactions