Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

MCP Learn - Model Context Protocol Examples

This repository contains examples of using the Model Context Protocol (MCP).

Overview

MCP allows Large Language Models (LLMs) to call external tools via a standardized protocol. This repository includes:

MCP clients

Agents that use MCP

MCP servers

Setup

Prerequisites

  1. Python 3.10 or higher
  2. uv for Python package management

Installation

# Clone this repository
git clone https://github.com/huangyingting/mcp-learn.git
cd mcp-learn

# Install dependencies
uv sync

Environment Setup

Create a .env file in servers, clients, and agents directories by copying the .env.example file to .env:

cp .env.example .env

Update the .env file with your Azure OpenAI API key and other configurations as needed.

Running the Examples

Starting a Server

All MCP servers are located in the servers/ directory. For example, to start the weather or stock server (both support two transport methods):

  1. stdio (default): For direct communication with the client
  2. sse: For running as a web server

To start a server with SSE transport:

uv run servers/any_mcp_server.py -t sse

When using the SSE transport, the server starts on http://localhost:8000/sse by default.

There is a composite server that aggregates all MCP servers. To start the composite server:

uv run servers/composite_server.py -t sse

Connecting the Client

Client are located in the clients/ directory. The client can connect to either a Python script server (stdio) or an SSE server:

To connect to a stdio server:

uv run clients/client.py servers/any_mcp_server.py

To connect to an SSE server:

uv run clients/client.py http://localhost:8000/sse

Once connected, you can interact with the client by typing in queries. For example:

  • Weather server: "What's the weather forecast for latitude 40.7, longitude -74.0?" or "Are there any weather alerts in CA?"
  • Stock server: "What's the current price of AAPL?" or "Give me information about Google's stock"

Type quit or exit to end your session.

For the chainlit client, you can run it with the following command:

uv run chainlit run clients/chainlit_client.py --port 9000

Then, open your web browser and navigate to http://localhost:9000 to interact with the client.

Use the Agent

The agent is located in the agents/ directory. To run the agent, use the following command:

To run semantic kernel agent

uv run agents/sk_agent.py

To run langgraph agent

uv run agents/langgraph_agent.py

To run autogen agent

uv run agents/autogen_agent.py

To run openai agent

uv run agents/openai_agent.py

To run ADK agent

uv run adk web --port 9000

Then, open your web browser and navigate to http://localhost:9000 to interact with the agent through adk web.

To run pydantic agent

uv run agents/pydantic_agent.py

To run agno agent

uv run agents/agno_agent.py

To run smolagents agent

uv run agents/smol_agent.py

To run atomic agent

uv run agents/atomic_agent.py

Available MCP servers

Weather Server

  • get_alerts: Get weather alerts for a US state using a two-letter state code
  • get_forecast: Get a weather forecast for a location by latitude and longitude

Stock Server

  • current_date: Get the current date
  • stock_price: Get the stock price for a given ticker
  • stock_info: Get information about a company by ticker
  • income_statement: Get the quarterly income statement for a company

NL2SQL Server

  • query_sql: Execute a custom SQL query on the SQLite database
  • list_tables: List all tables in the SQLite database
  • describe_table: Get the structure of a specific table
  • execute_nonquery: Execute a non-query SQL statement (INSERT, UPDATE, DELETE, etc.)
  • database_info: Get general information about the connected SQLite database

Time Server

  • get_current_time: Get the current time in a specific timezone

Search Server

  • web_search: Search the web for a given query

News Server

  • news_top_headlines: Get top headlines from NewsAPI.
  • news_search: Search for news articles using NewsAPI.
  • news_sources: Get available news sources from

相关推荐

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

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • Byaidu
  • PDF科学纸翻译带有保留格式的pdf -基于ai完整保留排版的pdf文档全文双语翻译

  • Onelevenvy
  • Flock是一个基于工作流程的低音平台,可快速构建聊天机器人,抹布和协调多代理团队,由Langgraph,Langchain,Langchain,Fastapi和Nextjs提供支持。(羊群工作流工作流的低代码平台,rag rag rag 用于快速构建聊天机器人、 rag temant Agent fastem temantfaster和muti-agent agagent应用

  • n8n-io
  • 具有本机AI功能的公平代码工作流程自动化平台。将视觉构建与自定义代码,自宿主或云相结合,400+集成。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

    Reviews

    2.7 (6)
    Avatar
    user_Uraa73dC
    2025-04-23

    mcp-learn is an exceptional tool for anyone looking to deepen their knowledge. Created by huangyingting, this product stands out with its user-friendly interface and comprehensive materials. It's designed to make learning accessible and engaging. Highly recommend for learners of all levels!

    Avatar
    user_3VjvOlw2
    2025-04-23

    I recently tried the mcp-learn application by huangyingting, and it exceeded all my expectations! The platform is user-friendly and incredibly informative. I found the courses well-structured, making it easy to follow and learn at my own pace. If you're looking to deepen your knowledge efficiently, mcp-learn is definitely a great choice!

    Avatar
    user_sfGQm4jf
    2025-04-23

    mcp-learn by huangyingting is an exceptional learning tool. As a dedicated user, I truly appreciate its seamless integration and user-friendly interface. The starting URL and welcoming information make the initial setup a breeze. This resource has significantly improved my learning experience, providing valuable insights and efficient methods to master various subjects. Highly recommend it for anyone seeking a reliable and effective learning companion!

    Avatar
    user_GiKU06SL
    2025-04-23

    I have been using mcp-learn by huangyingting and it's truly a fantastic learning tool! The intuitive interface and engaging content make it easy to grasp complex concepts. Highly recommend it to anyone looking to enhance their learning experience.

    Avatar
    user_ZEtMMtFa
    2025-04-23

    As an avid user of mcp-learn, I can confidently say that this platform, created by huangyingting, is a game-changer in its field. It offers a seamless learning experience, rich with resources and user-friendly navigation. The welcoming message sets a positive tone right from the start, making it a pleasant journey for all learners. Highly recommend it!

    Avatar
    user_HS8N9MPQ
    2025-04-23

    I recently started using MCP-Learn by huangyingting, and it has transformed my learning experience! The straightforward URL and welcoming interface make it easy to dive right in and start absorbing new information. The application is well-designed and supports multiple languages, ensuring accessibility for users worldwide. Highly recommend it for anyone looking to enhance their skills and knowledge efficiently.