MyAIServ MCP Server
MCP 서버 - 모델 컨텍스트 프로토콜 API
MCP 서버는 LLM 모델과 애플리케이션 간의 상호작용을 위한 표준화된 인터페이스를 제공하는 모델 컨텍스트 프로토콜(MCP)의 FastAPI 기반 구현입니다.
특이점
🚀 FastAPI 및 비동기 작업을 기반으로 한 고성능 API
🔄 리소스, 악기, 프롬프트 및 샘플링을 포함한 전체 MCP 지원
📊 Prometheus 및 Grafana를 통한 모니터링 및 메트릭
🧩 새로운 도구를 추가하기 위한 간단한 인터페이스를 통한 확장성
📝 유연한 데이터 작업을 위한 GraphQL API
💬 실시간 상호작용을 위한 WebSocket 지원
🔍 Elasticsearch와 통합을 통한 의미 검색
🗃️ Redis를 통한 캐싱 으로 성능 향상
📦 Poetry를 통해 종속성을 관리하여 안정적인 패키지 관리를 제공합니다.
Related MCP server: MCP Platform
시작하기
설치
복제 저장소:
지엑스피1
Poetry를 설치하세요(아직 설치되지 않은 경우):
curl -sSL https://install.python-poetry.org | python3 -Poetry를 통해 종속성 설치:
poetry install
서버 시작
poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload또는 just 유틸리티를 통해서:
just run출시 후 API는 http://localhost:8000 에서 사용 가능합니다.
API 문서
Swagger UI: http://localhost:8000/docs
ReDoc: http://localhost:8000/redoc
GraphQL 플레이그라운드: http://localhost:8000/graphql
프로젝트 구조
myaiserv/
├── app/
│ ├── core/ # Базовые компоненты MCP
│ │ ├── base_mcp.py # Абстрактные классы MCP
│ │ └── base_sampling.py # Базовые классы для сэмплирования
│ ├── models/ # Pydantic модели
│ │ ├── mcp.py # Модели данных MCP
│ │ └── graphql.py # GraphQL схема
│ ├── services/ # Бизнес-логика
│ │ └── mcp_service.py # Сервис MCP
│ ├── storage/ # Хранилище данных
│ ├── tools/ # Инструменты MCP
│ │ ├── example_tool.py # Примеры инструментов
│ │ └── text_processor.py # Инструмент обработки текста
│ ├── utils/ # Утилиты
│ └── main.py # Точка входа FastAPI
├── app/tests/ # Тесты
├── docs/ # Документация
│ └── MCP_API.md # Описание API
├── pyproject.toml # Конфигурация Poetry и инструментов
└── .justfile # Задачи для утилиты just사용 가능한 도구
파일 시스템 도구
파일 읽기, 쓰기, 삭제, 나열 기능을 지원하는 파일 시스템 도구입니다.
curl -X POST "http://localhost:8000/tools/file_operations" \
-H "Content-Type: application/json" \
-d '{"operation": "list", "path": "."}'날씨 도구
좌표로 날씨 데이터를 얻는 도구입니다.
curl -X POST "http://localhost:8000/tools/weather" \
-H "Content-Type: application/json" \
-d '{"latitude": 37.7749, "longitude": -122.4194}'텍스트 분석 도구
감정 감지 및 요약을 포함한 텍스트 분석을 위한 도구입니다.
curl -X POST "http://localhost:8000/tools/text_analysis" \
-H "Content-Type: application/json" \
-d '{"text": "Example text for analysis", "analysis_type": "sentiment"}'텍스트 프로세서 도구
서식 지정, 통계 계산, 엔터티 추출 등을 포함한 텍스트 처리를 위한 도구입니다.
curl -X POST "http://localhost:8000/tools/text_processor" \
-H "Content-Type: application/json" \
-d '{"operation": "statistics", "text": "Example text", "stat_options": ["chars", "words"]}'이미지 처리 도구
크기 조절, 자르기, 필터 적용을 지원하는 이미지 처리 도구입니다.
curl -X POST "http://localhost:8000/tools/image_processing" \
-H "Content-Type: application/json" \
-d '{"operation": "resize", "image_data": "base64...", "params": {"width": 800, "height": 600}}'웹소켓 API
WebSocket API에 연결하려면:
const socket = new WebSocket("ws://localhost:8000/ws");
socket.onopen = () => {
socket.send(JSON.stringify({
type: "initialize",
id: "my-request-id"
}));
};
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log("Received:", data);
};GraphQL API
GraphQL을 통한 쿼리의 예:
# Получение списка всех инструментов
query {
getTools {
name
description
}
}
# Выполнение инструмента
mutation {
executeTool(input: {
name: "text_processor",
parameters: {
operation: "statistics",
text: "Example text for analysis"
}
}) {
content {
type
text
}
is_error
}
}테스트 실행
테스트를 실행하려면 Poetry를 사용하세요.
poetry run pytest또는 just 유틸리티를 통해서:
just test도커
Docker Compose를 통한 빌드 및 실행
docker compose up -d개별 서비스를 시작하려면:
docker compose up -d web redis elasticsearchLLM과의 통합
MCP 서버는 다양한 공급업체의 LLM 모델과의 통합을 위한 표준화된 인터페이스를 제공합니다.
import httpx
async def query_mcp_with_llm(prompt: str):
async with httpx.AsyncClient() as client:
# Запрос к MCP для получения контекста и инструментов
tools_response = await client.get("http://localhost:8000/tools")
tools = tools_response.json()["tools"]
# Отправка запроса к LLM с включением MCP контекста
llm_response = await client.post(
"https://api.example-llm.com/v1/chat",
json={
"messages": [
{"role": "system", "content": "You have access to the following tools:"},
{"role": "user", "content": prompt}
],
"tools": tools,
"tool_choice": "auto"
}
)
return llm_response.json()지표 및 모니터링
MCP 서버는 /metrics 엔드포인트를 통해 Prometheus 형식의 메트릭을 제공합니다. 측정항목은 다음과 같습니다.
각 도구에 대한 요청 수
쿼리 실행 시간
오류 및 예외
개발
코드를 포맷하고 린터로 확인하려면 다음을 수행합니다.
just fmt
just lint특허
This server cannot be deployed
Maintenance
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for building and testing AI agents with multi-model experimentation and insights.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA high-performance Model Context Protocol (MCP) server designed for large language models, enabling real-time communication between AI models and applications with support for session management and intelligent tool registration.2MIT
- FlicenseNot gradedqualityNot gradedmaintenanceHigh-performance Model Context Protocol server supporting multiple LLM providers (OpenRouter, OpenAI, Groq) with WebSocket API and conversation history persistence.-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server implementation built with FastAPI that enables AI agent interactions. Provides a structured foundation for building AI-powered applications with proper data validation and modern Python tooling.-
- FlicenseNot gradedqualityNot gradedmaintenanceA production-ready Model Context Protocol server built with FastAPI, featuring JWT authentication, PostgreSQL database support, Redis caching, and comprehensive health monitoring for building secure async API applications.-