graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Add support for Model Context Protocol

Open casperOne opened this issue 9 months ago • 5 comments

Product

Hot Chocolate

Is your feature request related to a problem?

Model Context Protocol was generated as a standard to connect AI systems to data sources in a dynamic way.

Here is the overall architecture (screen capture from https://modelcontextprotocol.io/introduction):

Image

MCP clients interact with MCP servers through tools, resources and prompts, all of which are dynamically discovered by the clients.

These tools provide additional language/information about the actions that can be taken, parameters, data types on input and output, as well as descriptions for everything.

This allows the LLM to interpret the best tool to call along with the appropriate parameters based on the prompt the LLM has received.

Where does GraphQL/HotChocolate come in?

GraphQL has many of the prerequisites for generating an MCP server:

  • A type system with descriptions for all inputs/outputs
  • Fields on queries and mutations are akin to tools

The solution you'd like

It would be valuable for users of HotChocolate be able to leverage their infrastructure for GraphQL to expose an MCP server.

There are already existing projects which ingest GraphQL schemas and expose them as MCP servers:

https://github.com/hannesj/mcp-graphql-schema https://github.com/blurrah/mcp-graphql

Additionally, Microsoft has an official MCP server toolkit for C#:

https://github.com/modelcontextprotocol/csharp-sdk

Finally, the specification:

https://spec.modelcontextprotocol.io/specification/2025-03-26/

casperOne avatar Mar 29 '25 22:03 casperOne

I have put this on the next release ... we already had conversations around this with the DAB team.

michaelstaib avatar Mar 31 '25 08:03 michaelstaib

https://github.com/hannesj/mcp-graphql-schema https://github.com/blurrah/mcp-graphql

These seem pretty limited, i.e. they just expose generic tools to invoke/introspect. I think a better way to do it would be exposing every query/mutation as a separate tool, which should improve discoverability and would be also more precise in the parameter types for example as they could be translated roughly into JSON schema. A blocklist/allowlist would be useful too. A generic tool could be written probably but it would be easier to just have this built into HotChocolate (fewer moving parts etc)

mausch avatar Apr 19 '25 14:04 mausch

Considering Data API builder (preliminary, of course):

"mcp": {
  "enabled": true,
  "path": "/mcp",
  "cache": { ... },
  "white-list": {
    "http://localhost": {
      "scopes": [ "*", "mcp.read", "mcp.write" ],
      "role-override": "mcp-client"
    }
  },
  "permissions": {
    "anonymous": {
      "allowed-actions": [
        "list-types",
        "get-type",
        "list-query-fields",
        "get-query-field"
      ],
      "mutation-enabled": false,
      "schema-filters": {
        "exclude-types": [ "__InternalType" ],
        "exclude-fields": {
          "User": [ "passwordHash", "ssn" ],
          "Admin": [ "accessToken" ]
        }
      }
    },
    "admin": {
      "allowed-actions": [ "*" ],
      "mutation-enabled": true
    }
  },
  "response": {
    "max-types": 100,
    "max-depth": 10,
    "max-fields-per-type": 50,
    "max-rows-per-type": 1000
  }
}

JerryNixon avatar Apr 21 '25 22:04 JerryNixon

@mausch We’re not following the broader ecosystem here—much of it feels like throwing ideas at the wall that will soon be binned. We believe we have a much stronger, more coherent story that fuses GraphQL semantics with the stateful model underlying MCP.

We’ll be sharing more soon, including the first preview bits. The integration will debut in the new Hot Chocolate Fusion gateway and roll out to core Hot Chocolate by August.

michaelstaib avatar Apr 22 '25 19:04 michaelstaib

The real question remains around configurable control. It will be important.

JerryNixon avatar Apr 28 '25 17:04 JerryNixon