
MCP-Learn
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
- A cmdline client that can connect to any MCP server (
clients/cmd_client.py
) - A chainlit client that can connect to any MCP server (
clients/chainlit_client.py
)
Agents that use MCP
- A langgraph agent that uses MCP to call external tools (
agents/langgraph_agent.py
) - A semantic kernel agent that uses MCP to call external tools (
agents/sk_agent.py
) - An autogen agent that uses MCP to call external tools (
agents/autogen_agent.py
) - An openai agent that uses MCP to call external tools (
agents/openai_agent.py
) - An ADK(google) agent that uses MCP to call external tools (
agents/adk_agent
) - A pydantic agent that uses MCP to call external tools (
agents/pydantic_agent.py
) - An agno agent that uses MCP to call external tools (
agents/agno_agent.py
) - A smolagents agent that uses MCP to call external tools (
agents/smol_agent.py
) - An atomic agent that uses MCP to call external tools (
agents/atomic_agent.py
)
MCP servers
- A weather information server that provides weather forecasts and alerts (
servers/weather_server.py
) - A stock information server that provides stock prices and company information (
servers/stock_server.py
) - A NL2SQL server that translates natural language queries to SQL (
servers/nl2sql_server.py
) - A time server that provides the current time (
servers/timer_server.py
) - A search server that provides search capabilities (
servers/search_server.py
) - A composite server that aggregrtes all MCP servers (
servers/composite_server.py
)
Setup
Prerequisites
- Python 3.10 or higher
- 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):
- stdio (default): For direct communication with the client
- 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
相关推荐
Flock是一个基于工作流程的低音平台,可快速构建聊天机器人,抹布和协调多代理团队,由Langgraph,Langchain,Langchain,Fastapi和Nextjs提供支持。(羊群工作流工作流的低代码平台,rag rag rag 用于快速构建聊天机器人、 rag temant Agent fastem temantfaster和muti-agent agagent应用
😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack
Reviews

user_Uraa73dC
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!

user_3VjvOlw2
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!

user_sfGQm4jf
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!

user_GiKU06SL
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.

user_ZEtMMtFa
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!

user_HS8N9MPQ
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.