Enables conversion of FastAPI applications into MCP servers, allowing API endpoints to be exposed as MCP components with automatic integration of Swagger UI for API documentation.
Provides Swagger UI integration for API documentation and testing, with automatic generation of OpenAPI specifications for the MCP server endpoints.
FastMCP OpenAPI 자동 생성 데모
이 프로젝트는 FastMCP를 사용하여 OpenAPI 스펙에서 자동으로 MCP(Model Context Protocol) 서버를 생성하고 Swagger UI를 제공하는 데모입니다.
🌟 주요 기능
- OpenAPI 스펙 자동 변환: OpenAPI 3.0 스펙을 MCP 서버로 자동 변환
- FastAPI 통합: FastAPI 앱을 MCP 서버로 자동 변환
- Swagger UI 제공: 웹 브라우저에서 API 문서 확인 가능
- 자동 테스트: 생성된 MCP 서버의 기능을 자동으로 테스트
- 현대적인 도구: uv, pyproject.toml 사용
🚀 빠른 시작
1. uv 설치 (권장)
2. 프로젝트 설정
3. 데모 실행
🛠️ 개발 환경 설정
코드 품질 도구
새로운 의존성 추가
📋 해결된 문제들
❌ 기존 문제점들
- 테스트 오류:
'list' object has no attribute 'tools'
- asyncio 충돌:
Already running asyncio in this thread
- MCP 엔드포인트 404:
/mcp
경로 접근 불가 - 패키지 관리: 느린 pip, 복잡한 가상환경 관리
✅ 해결 방안
- API 호환성 개선: tools/resources 객체 타입 검사 추가
- 독립 서버 생성:
standalone_mcp_server.py
로 asyncio 충돌 해결 - FastAPI 통합 개선: MCP 정보 엔드포인트 추가
- 현대적인 도구: uv 사용으로 빠른 의존성 관리
🌐 웹 인터페이스
FastAPI 서버 실행 후 브라우저에서 다음 URL 접속:
- 메인 페이지: http://localhost:8000
- FastAPI Swagger UI: http://localhost:8000/docs ⭐ 권장
- 커스텀 Swagger UI: http://localhost:8000/swagger
- MCP 정보: http://localhost:8000/mcp/info
- OpenAPI 스펙: http://localhost:8000/openapi.json
📋 파일 구조
🔧 구현 방법
1. OpenAPI 스펙에서 MCP 서버 생성
2. FastAPI 앱에서 MCP 서버 생성
🧪 테스트
🆚 uv vs pip 비교
기능 | uv | pip |
---|---|---|
속도 | 🚀 10-100배 빠름 | 🐌 느림 |
의존성 해결 | ✅ 고급 알고리즘 | ⚠️ 기본적 |
가상환경 | ✅ 통합 관리 | ❌ 별도 도구 필요 |
잠금 파일 | ✅ uv.lock | ❌ 없음 |
크로스 플랫폼 | ✅ 일관된 경험 | ⚠️ 플랫폼별 차이 |
💡 uv 사용 팁
🤝 기여하기
- 저장소를 포크합니다
- 기능 브랜치를 만듭니다:
git checkout -b feature/amazing-feature
- uv를 사용해 개발 환경을 설정합니다:
uv sync --dev
- 코드 품질 도구를 실행합니다:
uv run black . && uv run ruff check .
- 테스트를 실행합니다:
uv run pytest
- 변경사항을 커밋합니다:
git commit -m 'Add amazing feature'
- 브랜치에 푸시합니다:
git push origin feature/amazing-feature
- Pull Request를 엽니다
📄 라이센스
이 프로젝트는 MIT 라이센스 하에 배포됩니다.
📞 지원
문제가 있거나 질문이 있으시면 이슈를 생성해 주세요.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A demonstration server that automatically generates Model Context Protocol (MCP) servers from OpenAPI specifications, providing seamless integration with FastAPI and supporting various transmission methods like STDIO, HTTP, and SSE.
Related MCP Servers
- AsecurityAlicenseAqualityA beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.Last updated -3936JavaScriptApache 2.0
- -securityAlicense-qualityAn MCP server that exposes HTTP methods defined in an OpenAPI specification as tools, enabling interaction with APIs via the Model Context Protocol.Last updated -2PythonMIT License
- -securityFlicense-qualityA Model Context Protocol server implementation that enables connection between OpenAI APIs and MCP clients for coding assistance with features like CLI interaction, web API integration, and tool-based architecture.Last updated -28Python
- -securityAlicense-qualityA command-line tool that transforms any OpenAPI service into a Model Context Protocol (MCP) server, enabling seamless integration with AI agents and tools that support the MCP specification.Last updated -902TypeScriptMIT License