Cover image
模型-Context-protocol-MCP-Demo-with-nangchain-mcp-apapters-collama
Public

模型-Context-protocol-MCP-Demo-with-nangchain-mcp-apapters-collama

Try Now
2025-04-13

使用Langchain MCP适配器和Ollama实施MCP的演示

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

🧠 Model Context Protocol (MCP)

An open-source standard to seamlessly connect Large Language Models (LLMs) with the external world — databases, APIs, services, and more.


🌐 What is MCP?

Model Context Protocol (MCP) is a new open-source protocol designed to empower LLMs by enabling them to interface with external tools, services, and data sources. Acting as a translator layer, MCP allows models to interact with APIs, databases, and other services in a standardized, extensible, and scalable way.


🚨 The Problem

LLMs alone can't execute real-world tasks — they only generate text. To build powerful AI assistants, we need to integrate them with tools like:

  • Email services
  • Search APIs
  • Databases
  • Custom scripts

But integrating multiple tools is hard. APIs vary widely, maintenance is a headache, and scalability is painful.


✅ MCP as a Solution

MCP provides a standardized interface that abstracts away the complexities of tool integration. Similar to how REST standardized web services, MCP standardizes how LLMs talk to tools — making integration cleaner, easier, and future-proof.


🔮 Why MCP?

MCP helps you build agents and complex workflows on top of LLMs. LLMs frequently need to integrate with data and tools, and MCP provides:

  1. A growing list of pre-built integrations that your LLM can directly plug into
  2. The flexibility to switch between LLM providers and vendors
  3. Best practices for securing your data within your infrastructure

🧩 Architecture & Components

Component Description
MCP Client The LLM-facing component. Can reside in chat apps, dev tools, or assistants.
MCP Server Built by service providers. Translates service functionality (e.g., database queries, API calls) into a format LLMs can understand.
MCP Protocol The two-way transport layer enabling secure, structured communication between client and server.
Service The actual tool or external resource being accessed (e.g., Weather API, SQL DB).

🔁 How It Works (Flow Example)

  1. User sends query via an MCP host (e.g., chat app).
  2. MCP Client identifies the need for an external tool.
  3. MCP Server advertises available tools.
  4. LLM decides which tool(s) to use and instructs the client.
  5. Client sends request to relevant MCP Server.
  6. Server connects to the external service and retrieves data.
  7. Response flows back to the LLM for final output generation.

✨ Key Benefits

  • Simplified Tool Integration
  • 🚀 Extended LLM Capabilities
  • 🛠️ Scalable, Maintainable Architecture
  • 🤝 Standardized Communication Layer
  • 💡 Fosters Innovation for AI App Developers

🛠️ Tech Stack Used

  • Python - Python forms the backbone of CodeBuddy, providing robust support for integration with various libraries and frameworks.
  • Langchain - LangChain is a framework designed to simplify the creation of applications using large language models.
  • Ollama - It provides a simple API for creating, running, and managing models, as well as a library of pre-built models that can be easily used in a variety of applications.
  • langchain-mcp-adapters - This library provides a lightweight wrapper that makes Anthropic Model Context Protocol (MCP) tools compatible with LangChain and LangGraph.

🧩 Files Overview

File Description
client.py A basic MCP client interacting only with a single mathserver.
mathserver.py An MCP server that exposes simple math operations (e.g., addition, multiplication).
weatherserver.py An MCP server simulating weather data responses.
multiclient.py A multi-client setup where the MCP client can connect to both the math and weather servers.

🔄 How It Works

  1. The client.py script simulates an AI assistant (or LLM) interacting with the Math MCP Server only.

  2. The multiclient.py script demonstrates a more advanced use-case where the MCP client discovers and uses tools from multiple servers (Math + Weather).

  3. mathserver.py and weatherserver.py expose capabilities that can be consumed by MCP clients.

🚀 Running the Demo

  1. Start the Servers:

    python mathserver.py
    python weatherserver.py
    
    
  2. Run Single-Client Demo:

    python client.py
    
    
  3. Run Multi-Client Demo:

    python multiclient.py
    
    

🚀 Get Involved

Contributions are welcome! If you have suggestions or would like to enhance this project, please fork the repository and submit a pull request.

Interested in contributing to MCP? Stay tuned for:

  • Contribution guidelines
  • Roadmap
  • Issue templates

Feel free to ⭐️ the repo and join the discussion!


License

This project is licensed under the MIT License. See the LICENSE file for more details.

相关推荐

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

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

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

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

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

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

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

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

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

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

  • chongdashu
  • 使用模型上下文协议(MCP),启用Cursor,Windsurf和Claude Desktop等AI助手客户,以通过自然语言控制虚幻引擎。

  • wgpsec
  • 一款基于各大企业信息api的工具,解决在遇到的各种针对国内企业信息收集难题。一键收集控股公司icp 备案、 app 、小程序、微信公众号等信息聚合导出。支持 mcp接入

    Reviews

    1 (1)
    Avatar
    user_Hbru00pX
    2025-04-17

    As a dedicated user of the Model-Context-Protocol (MCP) applications, I am thoroughly impressed with the Model-Context-Protocol-MCP-Demo-with-langchain-MCP-ADAPTERS-Ollama by Ginga1402. This demo showcases the seamless integration and adaptability of MCP in various scenarios, making it a must-try for anyone in the field. The clear documentation and ease of use make it accessible, and the potential for customization provides endless possibilities. Highly recommend checking it out on GitHub!