Skip to main content
Glama

Basic MCP Application

基本 MCP 应用程序

一个简单的应用程序,展示了模型上下文协议 (MCP) 如何与 FastAPI 和 Gradio 配合使用(因为我不是一个喜欢 Streamlit 头痛的开发人员)。

概述

该项目演示了一个带有 Gradio 前端的基本 MCP 服务器(Streamlit 令人头疼,人生苦短,不值得承受不必要的痛苦)。用户可以通过营销人员称之为“简单界面”和开发人员称之为“在我离开之前能做的最好的事情🥲”的方式与 AI 模型聊天。

技术堆栈

  • 后端:FastAPI + MCP Python SDK(天作之合,不像披萨上放菠萝)
  • 前端:Gradio(因为漂亮的按钮会让多巴胺兴奋起来)
  • AI 集成:Google Gemini API(不是星座,而是 Sundar Pichai 的 AI AI AI AI AI AI 东西)

已知问题

⚠️请注意

  • 引用工具目前无法正常工作。您在分析论文引用或使用某些高级搜索功能时可能会遇到错误。我正在努力修复这个问题。什么时候能修复?谁知道呢¯\_(ツ)_/¯。也许等我们有了通用人工智能 (AGI) 之后再说吧。
  • Semantic Scholar API 存在速率限制,这可能会导致搜索功能有时返回错误消息“我无法直接搜索并提供论文”。当免费 API 遇到热情用户时,就会出现这种情况——我们爱死它们了。请稍等片刻,然后重试(或者在速率限制重置时喝杯咖啡分散一下注意力)。

加快您的设置速度

这个项目与uv完美兼容,uv 是一款超快的 Python 软件包安装程序!无需等待 pip 下个世纪才能完成,使用uv几秒钟就能安装依赖项。我强烈推荐它,因为它能带来更流畅的体验(还能省去你盯着进度条的几个小时)。

快速入门

你需要什么

  • Python 3.11 或更新版本(抱歉,老古董们还在用 Python 2)
  • pip 包管理器(或者它的更酷、更快的表亲uv
  • RCB 的耐心(谷歌搜索)(可选但推荐)

设置步骤

  1. 克隆此项目:
    git clone https://github.com/yourusername/basic-mcp-app.git cd basic-mcp-app
  2. 创建一个虚拟环境(因为全局依赖是造成情感伤害的途径):
    python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
  3. 安装所需的软件包:使用 pip(乌龟方式):
    pip install -r requirements.txt
    使用 uv(实际上赢得比赛的野兔方式):
    # Install uv first if you don't have it curl -LsSf https://astral.sh/uv/install.sh | sh
    或者
    pip install uv
    然后使用 uv 安装依赖项:
    uv pip install -r requirements.txt
    使用uv让 Python 软件包安装变得飞快!它比普通的 pip 快得多(motherpromise🤞)。在 pip 理解你指令之前,uv 已经完成了安装,煮好了咖啡,然后开始为你编写下一个应用。
  4. 设置你的 API 密钥(你永远不应该提交到 GitHub 但总有人会这么做):
    cp .env.example .env # Open .env and add your API keys
  5. 使用一个命令运行两个服务器(像魔术一样,但带有更多分号):
    python run.py
    这会同时启动后端和前端。这就像鱼与熊掌兼得,但热量更低。如果需要的话,您还可以单独启动它们(对于我们当中的控制狂来说):
    • 后端: uvicorn backend.main:app --reload
    • 前端: python frontend/app.py
  6. 打开你的网络浏览器并转到http://localhost:8501 (如果这不起作用,请尝试将其关闭并重新打开😑)

项目文件

看看这个漂亮的目录结构,一旦开发真正开始,它就永远不会保持这么干净:

basic-mcp-app/ ├── .env.example # Template for your API keys(Please don't make your api keys public🙏) ├── .gitignore # Files to ignore in git (like the emotional baggage) ├── README.md # This help file that nobody reads until desperate ├── requirements.txt # Required packages (aka dependency hell) ├── run.py # Script to start both servers ├── backend/ │ └── main.py # Backend server code with MCP (where the real magic happens) └── frontend/ └── app.py # Gradio frontend interface (pretty buttons go here)

特征

  • 使用 Semantic Scholar 搜索科学论文(适用于 Google Scholar 过于主流的情况)
  • 论文分析工具(每次都有 60% 的效率)
  • 简单的聊天界面(对用户来说简单,对开发人员来说却是噩梦)
  • 简单的设置过程(如果您曾经攀登过珠穆朗玛峰,这会感觉就像在公园散步一样)

执照

MIT(因为我很友善,也不想阅读冗长的许可证)

谢谢

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

一个简单的应用程序,演示了模型上下文协议 (MCP) 与 FastAPI 和 Streamlit 的集成,允许用户通过干净的界面与 LLM 进行交互。

  1. 概述
    1. 技术堆栈
      1. 已知问题
        1. 加快您的设置速度
          1. 快速入门
            1. 你需要什么
            2. 设置步骤
          2. 项目文件
            1. 特征
              1. 执照
                1. 谢谢

                  Related MCP Servers

                  • -
                    security
                    A
                    license
                    -
                    quality
                    MCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.
                    Last updated -
                    13
                    2
                    TypeScript
                    MIT License
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A zero-configuration tool that automatically exposes FastAPI endpoints as Model Context Protocol (MCP) tools, allowing LLM systems like Claude to interact with your API without additional coding.
                    Last updated -
                    5,362
                    Python
                    MIT License
                    • Linux
                    • Apple
                  • A
                    security
                    A
                    license
                    A
                    quality
                    An educational implementation of a Model Context Protocol server that demonstrates how to build a functional MCP server for integrating with various LLM clients like Claude Desktop.
                    Last updated -
                    1
                    88
                    Python
                    MIT License
                    • Apple
                    • Linux
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A Model Context Protocol (MCP) server implementation that enables LLMs to interact with the Osmosis protocol, allowing for querying and transaction functionality through natural language.
                    Last updated -
                    9
                    TypeScript
                    MIT License
                    • Apple

                  View all related MCP servers

                  MCP directory API

                  We provide all the information about MCP servers via our MCP API.

                  curl -X GET 'https://glama.ai/api/mcp/v1/servers/priteshshah96/MCP'

                  If you have feedback or need assistance with the MCP directory API, please join our Discord server