atomic-server icon indicating copy to clipboard operation
atomic-server copied to clipboard

MCP (Model Context Provider) Support

Open joepio opened this issue 9 months ago • 10 comments

AtomicServer is a powerful and fast CMS / Graph Database with full-text search capabilities. It would be great if it also supported the modern MCP standard, which allows LLMs / AI models to perform search queries.

Of course, AtomicServer can be a data source for some MCP server. But a true MCP server also has the ability to say "these are the functions that are available here, and this is how you call them".

Options

Use a lightweight Python server, using FastMCP

  • I don't like adding a dependency to Python, makes the whole way more complicated and slow

AtomicServer adds MCP endpoints, in Rust

  • We can use a library likemcp_rust_sdk (example) to add MCP endpoints to AtomicServer.
  • Maybe it makes more sense to implement this semi-manually by adding an Actix endpoint and using the types from the mcp-rust-sdk crate
  • There's this async-mcp crate which uses Actix, and extended from this mcp-sdk crate (synchronous)

Client-only (virtual) MCP in Typescript

  • We create a virtual MCP server, in the client. This gives us access to write features, because we have the Agent + PrivateKey.
  • This does not give other MCP clients the possibility of using AtomicServer as a data source.

Related issues

  • #951

joepio avatar Feb 26 '25 09:02 joepio

For now, it seems best to go for the Client-Only Virtual MCP approach. This is the easiest for Polle and gives us the largest possible set of features (like write capabilities).

joepio avatar Mar 03 '25 15:03 joepio

Since we are building this in the client is is not possible to use MCP servers that use the stdio for communication. Sadly it doesn't look like there are a lot of SSE based MCP servers. The few I did try (mainly Composio and even Supergateway) had CORS disabled making them unusable in a browser context

Polleps avatar Mar 06 '25 14:03 Polleps

Hey @Polleps, we’ve just added --cors flag to Supergateway that enables CORS if you need it: https://github.com/supercorp-ai/supergateway?tab=readme-ov-file#installation--usage

Nedomas avatar Mar 12 '25 18:03 Nedomas

Hey @Polleps, we’ve just added --cors flag to Supergateway that enables CORS if you need it: https://github.com/supercorp-ai/supergateway?tab=readme-ov-file#installation--usage

I was about to make a pull request for it when I saw the changes haha, awesome work!

Polleps avatar Mar 12 '25 18:03 Polleps

One problem I'm facing is that JSON-AD might not be the best format for an LLM to use. There are a few issues:

  1. Models sometimes have trouble understanding it. For example when asked to change the name of a resource, they will sometimes try to change the name property of the name resource itself.
  2. The title of the property is not always in te subject. Or even worse, the title might have changes but the subject stays the same. This means the llm does not know what the property means or thinks it's something else.

Issue one could probably be fixed by explaining JSON-AD better in the system prompt. Issue two is a more difficult problem as the only fix is probably to use more standard JSON and have tools figure out what properties it wants to change by name instead of subject. However this becomes a problem when creating entirely new resources or adding new properties to existing resources

Polleps avatar Mar 17 '25 11:03 Polleps

For the Atomic Assistant usecase I think we really need some kind of RAG solution because right now asking general questions about the data is a bit hit or miss. A lot of the time it will not know what to search for or only search for a specific thing and not really give a good answer. Adding a good RAG feature requires a vector database though

Polleps avatar Mar 26 '25 12:03 Polleps

Related vector DB discussion: https://github.com/atomicdata-dev/atomic-server/issues/1007

joepio avatar Mar 27 '25 09:03 joepio

I just noticed that the MCP spec was changed. They replaced SSE with Streamable HTTP as the standard remote transport layer. I think the Vercel AI SDK we're using supports bringing your own transport so that is not an issue. I'm not sure if we should replace SSE right away or if we should support both for now by letting the user specify the type of transport.

Polleps avatar May 19 '25 14:05 Polleps

I ran into another issue, Vercel's AI Core sdk supports mcp via their own client but it does not expose anything except tools. To get around this I created an extra set of clients using the typescript sdk in a separate hook but I noticed that after I made that hook the tools stopped working. I think this is because there are multiple SSE connections being opened to the same server, maybe the messages get mixed up?

I don't know how to fix this

Polleps avatar May 22 '25 12:05 Polleps

I ran into another issue, Vercel's AI Core sdk supports mcp via their own client but it does not expose anything except tools. To get around this I created an extra set of clients using the typescript sdk in a separate hook but I noticed that after I made that hook the tools stopped working. I think this is because there are multiple SSE connections being opened to the same server, maybe the messages get mixed up?

I don't know how to fix this

I think the only way to fix this for now is to handle the tool calling ourselves again instead of using AI Core's client. This is what I did before the sdk had support for mcp tools but I ran into some issues with streams suddenly stopping without a reason.

Polleps avatar May 22 '25 14:05 Polleps