Awesome MCP FastAPI

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports environment variable configuration through .env files when running with Docker, as shown in the docker run command with --env-file flag.

  • Provides Docker support for building and running the MCP server in containers, with detailed instructions for Docker deployment.

  • The MCP server is built on FastAPI, leveraging its ecosystem for automatic OpenAPI documentation generation, dependency injection, middleware support, validation, and async capabilities.

멋진 MCP FastAPI

향상된 툴 레지스트리 기능을 갖춘 모델 컨텍스트 프로토콜(MCP)의 강력한 FastAPI 기반 구현으로, 성숙한 FastAPI 생태계를 활용합니다.

개요

Awesome MCP FastAPI는 모델 컨텍스트 프로토콜(Model Context Protocol)의 프로덕션 환경에 즉시 적용 가능한 구현으로, FastAPI의 강력한 생태계와 통합하여 표준 MCP 기능을 향상시키고 확장합니다. 이 프로젝트는 대규모 언어 모델(LLM)용 AI 도구를 더욱 쉽게 생성, 관리 및 문서화할 수 있도록 개선된 도구 레지스트리 시스템을 제공합니다.

이것이 표준 MCP보다 나은 이유

모델 컨텍스트 프로토콜은 AI 모델을 도구 및 데이터 소스에 연결하기 위한 견고한 기반을 제공하지만, 우리의 구현은 다음과 같은 몇 가지 중요한 이점을 제공합니다.

FastAPI의 성숙한 생태계

  • 프로덕션에 바로 적용 가능한 웹 프레임워크 : 자동 OpenAPI 문서 생성 기능을 갖춘 고성능 최신 웹 프레임워크인 FastAPI를 기반으로 구축되었습니다.
  • 종속성 주입 : FastAPI의 강력한 종속성 주입 시스템을 활용하여 유지 관리와 테스트가 용이한 코드를 만듭니다.
  • 미들웨어 지원 : 인증, 모니터링 및 기타 미들웨어 구성 요소와의 쉬운 통합.
  • 내장된 검증 기능 : 강력한 요청/응답 검증 및 데이터 모델링을 위한 Pydantic 통합.
  • 비동기 지원 : 높은 동시성 애플리케이션을 위한 비동기/대기 패턴에 대한 최고 수준의 지원.

향상된 도구 레지스트리

우리의 구현은 다음과 같은 측면에서 표준 MCP 도구 레지스트리를 개선합니다.

  • 자동 문서 생성 : 도구는 MCP 형식과 OpenAPI 사양으로 자동 문서화됩니다.
  • 개선된 유형 힌트 : 더 나은 툴링과 IDE 지원을 위해 향상된 유형 정보 추출 기능이 추가되었습니다.
  • 더욱 풍부한 스키마 정의 : 도구 입력 및 출력을 위한 더욱 표현력이 풍부한 JSON 스키마 정의.
  • 더 나은 오류 처리 : 자세한 정보를 포함한 체계적인 오류 응답.
  • 향상된 Docstring 지원 : Python docstring에서 문서를 더 잘 추출합니다.

추가 기능

  • CORS 지원 : 교차 출처 요청에 대비하여 웹 애플리케이션과 쉽게 통합할 수 있습니다.
  • 수명 관리 : FastAPI의 수명 API를 통해 적절한 리소스 초기화 및 정리를 수행합니다.

시작하기

필수 조건

  • 파이썬 3.10+

설치

지엑스피1

서버 실행

uvicorn src.main:app --reload

OpenAPI 문서를 보려면 http://localhost:8000/docs를 방문하세요.

용법

도구 만들기

from fastapi import FastAPI from src.utils.tools import auto_tool, bind_app_tools app = FastAPI() bind_app_tools(app) @auto_tool( name="calculator", description="Perform basic arithmetic operations", tags=["math"] ) @app.post("/api/calculator") async def calculator(operation: str, a: float, b: float): """ Perform basic arithmetic operations. Parameters: - operation: The operation to perform (add, subtract, multiply, divide) - a: First number - b: Second number Returns: The result of the operation """ if operation == "add": return {"result": a + b} elif operation == "subtract": return {"result": a - b} elif operation == "multiply": return {"result": a * b} elif operation == "divide": if b == 0: return {"error": "Cannot divide by zero"} return {"result": a / b} else: return {"error": f"Unknown operation: {operation}"}

MCP를 통한 도구 액세스

LLM은 모델 컨텍스트 프로토콜을 통해 도구를 검색하고 사용할 수 있습니다. Claude를 사용한 예시:

You can perform calculations using the calculator tool. Try calculating 42 * 13.

클로드는 자동으로 계산기 도구를 찾아 계산을 수행합니다.

건축학

우리의 애플리케이션은 모듈형 아키텍처를 따릅니다.

src/ ├── api/ # API endpoints │ └── v1/ # API version 1 ├── core/ # Core functionality │ └── settings.py # Application settings ├── db/ # Database connections │ └── models/ # Database models ├── main.py # Application entry point └── utils/ # Utility functions └── tools.py # Enhanced tool registry

도커 지원

Docker로 빌드하고 실행:

docker build -t awesome-mcp-fastapi . docker run -p 8000:8000 --env-file .env awesome-mcp-fastapi

기여하다

기여를 환영합니다! 풀 리퀘스트를 제출해 주세요.

특허

이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.

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

FastAPI로 구축된 프로덕션에 바로 적용 가능한 MCP 서버로, 대규모 언어 모델(LLM)을 위한 AI 도구를 만들고, 관리하고, 문서화하기 위한 향상된 도구 레지스트리를 제공합니다.

  1. Overview
    1. Why This Is Better Than Standard MCP
      1. FastAPI's Mature Ecosystem
      2. Enhanced Tool Registry
      3. Additional Features
    2. Getting Started
      1. Prerequisites
      2. Installation
      3. Running the Server
    3. Usage
      1. Creating a Tool
      2. Accessing Tools Through MCP
    4. Architecture
      1. Docker Support
        1. Contributing
          1. License
            ID: 2ysi73d5t3