MCP ExplorerExplorer

Modelcontextprotocolserver

@InnoBridgeon a year ago
1 MIT
FreeCommunity
AI Systems
MCP server to provide tools

Overview

What is Modelcontextprotocolserver

ModelContextProtocolServer is an MCP server designed to provide various tools and functionalities through a structured API, enabling seamless integration and interaction with different services.

Use cases

Use cases for ModelContextProtocolServer include building applications that require real-time weather updates, performing calculations through a web interface, and integrating different services that require tool-based interactions.

How to use

To use ModelContextProtocolServer, you can connect to the SSE stream using a curl command, generate a Java artifact using Maven, and start the server with specific Java options. You can then send requests to the server to utilize various tools like a calculator or weather service.

Key features

Key features of ModelContextProtocolServer include support for SSE streaming, a simple API for tool interaction, the ability to handle JSON-RPC requests, and the provision of various built-in tools such as a calculator and a weather information service.

Where to use

ModelContextProtocolServer can be used in various fields such as web development, data processing, and application integration, where there is a need for tool-based functionalities and real-time data streaming.

Content

ModelContextProtocolServer

API Examples

Connect to SSE stream

curl -N -H "Accept: text/event-stream" http://localhost:8081/sse

Connect to stdio

Generate Java artifact

./mvnw clean install

Starting stdio server

java -Dtransport.mode=stdio \
     -Dspring.main.web-application-type=none \
     -Dspring.main.banner-mode=off \
     -Dlogging.file.name=mcpserver.log \
     -jar target/mcpserver-0.0.1-SNAPSHOT.jar

Send a tool/list request

Example

Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' http://localhost:8081/mcp/message

Respone

event:message
data:{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"calculator","description":"Basic calculator","inputSchema":{"type":"object","properties":{"operation":{"type":"string"},"a":{"type":"number"},"b":{"type":"number"}},"required":["operation","a","b"]}},{"name":"get_current_weather","description":"Get the current weather in a given location","inputSchema":{"type":"object","properties":{"location":{"type":"string","description":"The name of the city e.g. San Francisco, CA"},"format":{"type":"string","enum":["celsius","fahrenheit"],"description":"The format to return the weather in"}},"required":["location"]}}]}}

Call the calculator tool

Example

Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"calculator","arguments":{"operation":"+","a":2,"b":3}}}' http://localhost:8081/mcp/message

Response

event:message
data:{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","type":"text","text":"2.00 + 3.00 = 5.00"}],"isError":false}}

Call the weather tool

Example

Request

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_current_weather","arguments":{"location":"San Francisco","format":"celsius"}}}' http://localhost:8081/mcp/

Response

event:message
data:{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","type":"text","text":"Current weather in San Francisco, United States of America: Partly cloudy, 11.1°C, Precipitation: 0.0 mm"}],"isError":false}}

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers