-
Notifications
You must be signed in to change notification settings - Fork 942
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
Support for MCP (Model Context Protocol) #6179
Comments
If you find value in this project, I am willing to pair-up to help. I have recently went ahead and helped a relatively new CLI tools for interacting MCPs to add HTTP support, so I am kinda familiar with the protocol now. |
I am also interested in MCP. It would be awesome if we could support MCP in Armeria. |
Here are some suggestions. public class MyMcpService implements McpService {
@Override
public Set<McpTool> tools() { ... }
@Override
public Set<McpResource> resources() { ... }
@Override
public Set<McpPrompt> prompts() { ... }
}
public class TellAgeTool implements McpTool {
@Override public String name = "tell-age";
@Override public String description = "Tells the age of a person";
@Override
public McpParams params() {
return McpParams.of(
McpParams.string("name"),
McpParams.int("age").withDescription("Age of the person"),
);
}
@Override
public ToolResponse handle(McpParams params) {
String name = params.string("name");
Int age = params.int("age").orDefault(0);
return ToolResponse.ofText("Hello " + name ", you are " + age + " years old.");
}
}
public class PersonResource implements McpResource {
@Override public String name = "person";
@Override public String uri = "uri://person";
@Override
public ResourceResponse handle(params: McpParams) {
URI uri = params.uri("uri");
return ResourceResponse.ofImage(Images.get(uri).toBase64());
}
}
public class SamplePrompt implements McpPrompt {
@Override public String name = "person";
@Override
public ResourceResponse handle(params: McpParams) {
URI uri = params.uri("uri");
return ResourceResponse.ofImage(Images.get(uri).toBase64());
}
}
sb.serviceUnder("/mcp", MyMcpService()) For registering the entities, we can also use annotations, @McpService
public class MyMcpService {
// Auto-register schema from parameters
@Tool(name = "tellAge", description = "...")
public tellAge(
String name,
Int age,
) ToolResponse {
return ToolResponse.ofText("Hello " + name ", you are " + age + " years old.);
}
@Resource(uri = "file://person", name = "person", description = "...")
public person(ResourceParams params) ResourceResponse {
return ResourceResponse.ofImage(Images.get(params.uri).toBase64());
}
@Prompt()
public prompt(
String code
) PromptResponse {
return PromptResponse.ofResource("uri://...");
}
}
sb.mcpService("/mcp", MyMcpService())
// Or
sb.annotatedService("/mcp", MyMcpService()) |
I would like this, even though it is an interesting challenge for trace propagation. Suggest we support stdio mode as well, even though that isn't typical for armeria. Rationale is well engineered i/o is a win even if using stdio. |
From, https://modelcontextprotocol.io/introduction
This protocol is relatively new and there is a lot of hype around it. I think there is value in creating an experimental module to add MCP support in Armeria. I think it can boost the project's popularity as well.
For example, Http4k added it recently: https://www.http4k.org/news/http4k_mcp_has_landed/
And Spring boot: https://docs.spring.io/spring-ai-mcp/reference/overview.html
As current implementation of MCP uses SSE, it should be relatively easy to abstract out the MCP protocol as a separate HttpService.
The text was updated successfully, but these errors were encountered: