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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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
Pluginand integrate it into Unity. Then, via TCP connection with MCPServerthey can talk to each other. The code which is responsible for takingresourcesor running atoolshould be in Unity as part of thePlugin. Unfortunately because of the currentcsharp-sdklimitation, a function for atoolshould 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 customtoolsin 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 customtoolsoutside of read-only package.csharp-sdkhad an API for dynamic add of amethod, but that should be a realmethodwith 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 istoolexecutor,resourceloader,tools listprovider,promptprovider to theServerTarget- Unity Editor, a game, any software such as Blender, Photoshop, 3DS Max etc.The
Pluginis the core in this concept.Serveris only a data router and connector.Plugin'sresponsibilities:ServerServerabout internal events if neededServerif connection lostServer'sresponsibilities:Plugincapabilities (tools, resources, prompts) and updates toClientClientrequests toPluginPlugincapabilities provide it's own capabilities (needed for the specific category of tools, for example when theTargetandPluginshould be restarted by a command fromClient.Pluginif connection lostIdeal solution 💖
csharp-sdkmay support "Plugin" mode. It is similar to existedcsharp-sdkarchitecture which supportsClientandServermodes, that is anotherPluginmode. It would require to have TCP connection betweenServerandPlugin.Pluginmode supports the same style of method binding likecsharp-sdkworks for a Server already with attributes.Pluginautomatically shares and updates current capabilities withServervia TCP connection.Pluginis independent fromServerand may life without connection. There is nothing to do with that, it just waits for connection withServerBy 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
Pluginconcept is a bit out of the scope for thecsharp-sdkfor MCP. That is why I have the Minimal solution, which is really required such as a last jigsaw in the puzzle.Minimal solution ⭐
Servermode and providing response to aClient.toolwithout 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.NotifyTooListChangedmethod. 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-sdkdevelopers and MCP server developers. We (MCP server devs) don't need to worry about about managing thetoolsreactive 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