Cover image
Try Now
2025-04-01

Java模型上下文协议SSE HTTP服务器带JETTY

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

Weather Java SSE Transport MCP Service

A working implementation Model Context Protocol java-sdk. Includes a fast-agent for the MCP Client to interact with the Weather mcp-server.

⚠️This isn't remotely production grade, just demonstrating how to build something working end to end that can leverage multiple MCP Servers both local (Stdio Transport) and remote (HTTP SSE Transport). Also avoids pulling in as much of Spring as possible, for those who don't want it.

In the demo, you'll see the agent:

  1. The agent uses Claude Sonnet 3.7 throughout for the LLM bits
  2. The agent calls out to the "fetch" websearch MCP Server tool to look up lat/long for each city I asked for.
  3. The agent then uses those lat/long values to call the weather MCP Server tool (implemented in this repository). You can see the calls being made in the upper half of the terminal split window.
  4. The agent summarizes the forecasts and determine which of the 4 cities is the warmest tomorrow.

The agent is figuring out which tools to call from the context of the user's inputted prompts.

Description of image

build and start Weather MCP Server

mvn clean package
java -jar java -jar mcp-server/target/mcp-server-1.0-SNAPSHOT.jar

install, configure, and start fast-agent

install

pip install uv
uv pip install fast-agent-mcp
uv run agent.py

Configure Claude and OpenAI api keys

cp fastagent.secrets.yaml.TEMPLATE fastagent.secrets.yaml

then add your api keys to that config file.

Note: Weather MCP Server config

Note, in fastagent.config.yaml we've configured the MCP Servers available to the agent, in this case our server uses the SSE HTTP Transport, this enables calling remote MCP Servers :).

mcp:
    servers:
        weather:
            transport: "sse"
            read_timeout_seconds: 10
            url: "http://localhost:8080/sse"

Lower level for testing

Connect to SSE stream

curl -v -H "Accept: text/event-stream" "http://localhost:8080/sse"

Send messages to /mcp/messages (note, include sessionId from SSE)

curl -X POST "http://localhost:8080/mcp/message?sessionId=b64ad193-6bb3-4e2e-b33c-27a23011acb4" -d '{"hi": "mynameis"}' | jq .

Things to check out:

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • J. DE HARO OLLE
  • Especialista en juegos de palabras en varios idiomas.

  • albert tan
  • Japanese education, creating tailored learning experiences.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • HiveNexus
  • 一个适用于中小型团队的AI聊天机器人,支持DeepSeek,Open AI,Claude和Gemini等车型。 专为中小团队设计的ai聊天应用,支持deepSeek,打开ai,claude,双子座等模型。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • JackKuo666
  • 🔍使AI助手可以通过简单的MCP接口搜索和访问PYPI软件包信息。

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

    Reviews

    4 (1)
    Avatar
    user_DmlI4l7S
    2025-04-16

    MySQL MCP Server by wuwen1030 is an impressive tool for database management. Its robust functionality and seamless integration have significantly improved my workflows. The detailed documentation and user-friendly interface make it accessible for users at all levels. Highly recommend this server for anyone looking for reliable and efficient MySQL management.