Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run MCP server in backend using Grafana Live #574

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

sd2k
Copy link
Contributor

@sd2k sd2k commented Feb 27, 2025

This PR adds three main things:

MCP server

The backend plugin now runs an MCP server using Grafana Live, using what is effectively a new transport. Each session is stored in a sync.Map. Similar to the SSE transport, clients receive data over the stream and can send requests by publishing to the stream.

Frontend helpers

There are a few helpers added to the frontend to make this possible (or easier) to use. Specifically:

  • GrafanaLiveTransport, a custom transport for MCP clients that uses the Grafana Live Protocol to communicate with the MCP server.
  • the MCPClientProvider component, which is a React context provider that provides an MCPClient instance to the rest of the application.
  • a convenience hook, useMCPClient, that fetches the MCPClient instance from the context.

Frontend type updates

The OpenAI types were woefully out of date; this updates various function/tool call related ones.


There's an example of all this being used in this PR to the grafana-plugin-examples repo.

sd2k added 10 commits February 26, 2025 16:18
This commit adds support for the MCP server to the frontend library.
It provides:

- `GrafanaLiveTransport`, a custom transport for MCP clients that
  uses the Grafana Live Protocol to communicate with the MCP server.
- the `MCPClientProvider` component, which is a React context provider
  that provides an `MCPClient` instance to the rest of the application.
- a convenience hook, `useMCPClient`, that fetches the `MCPClient` instance
  from the context.
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.

1 participant