유용한 모델 컨텍스트 프로토콜 서버(MCPS)
다양한 유틸리티 기능을 위한 모델 컨텍스트 프로토콜(MCP) 서버를 구현하는 독립형 Python 스크립트 모음입니다. 각 서버는 AI 어시스턴트 또는 MCP 프로토콜을 지원하는 다른 애플리케이션에서 사용할 수 있는 특수 도구를 제공합니다.
MCP란 무엇인가요?
모델 컨텍스트 프로토콜(MCP)은 AI 어시스턴트가 외부 도구 및 서비스와 상호 작용하는 표준화된 방식입니다. AI 모델은 MCP 서버에서 제공하는 특수 함수를 호출하여 기능을 확장할 수 있습니다. 통신은 JSON 메시지를 사용하는 표준 입출력(stdio)을 통해 이루어집니다.
사용 가능한 서버
각 MCP 서버는 uv
와 같은 Python 환경 관리자를 사용하여 실행되도록 설계되었습니다.
YouTube 데이터 추출기( ytdlp
)
yt-dlp를 사용하여 YouTube 동영상에서 정보를 추출하는 서버입니다.
도구:
- 챕터 추출 : YouTube 비디오에서 챕터 정보를 가져옵니다.
- 자막 추출 : YouTube 비디오의 특정 장이나 전체 비디오에 대한 자막을 가져옵니다.
MCP 서버 구성:
지엑스피1
워드 문서 프로세서( docx_replace
)
템플릿 처리, PDF 변환 등을 포함하여 Word 문서를 조작하기 위한 서버입니다.
도구:
- 프로세스 템플릿 : Word 템플릿의 자리 표시자를 바꾸고 콘텐츠 블록을 관리합니다.
- 템플릿 키 가져오기 : Word 문서 템플릿에서 모든 대체 키를 추출합니다.
- PDF로 변환 : Word 문서(docx)를 PDF 형식으로 변환합니다.
MCP 서버 구성:
"mcpServers": {
"docx_replace": {
"name": "docx", // Optional friendly name
"command": "uv",
"args": [
"run",
"--directory", "<path/to/repo>/useful-mcps/docx_replace", // Path to the MCP directory
"--",
"docx_replace_mcp" // Match the script name defined in pyproject.toml
]
}
}
PlantUML 렌더러( plantuml
)
PlantUML 서버(종종 Docker를 통해 실행)를 사용하여 PlantUML 다이어그램을 렌더링하는 서버입니다.
도구:
- 다이어그램 렌더링 : PlantUML 텍스트를 다이어그램 이미지(예: PNG)로 변환합니다.
MCP 서버 구성:
"mcpServers": {
"plantuml": {
"name": "plantuml", // Optional friendly name
"command": "uv",
"args": [
"run",
"--directory", "<path/to/repo>/useful-mcps/plantuml", // Path to the MCP directory
"--",
"plantuml_server" // Match the script name defined in pyproject.toml
]
}
}
(참고: 실행 중인 PlantUML 서버가 필요하며, 서비스에 구현된 Docker를 통해 관리될 가능성이 있음).
인어 렌더러( mermaid
)
mermaidchart.com API를 사용하여 인어 다이어그램을 렌더링하는 서버입니다.
도구:
- 인어 차트 렌더링 : mermaidchart.com에서 문서를 만들어 인어 코드를 PNG 이미지로 변환합니다.
MCP 서버 구성:
"mcpServers": {
"mermaid": {
"name": "mermaid", // Optional friendly name
"command": "uv",
"args": [
"run",
"--directory", "<path/to/repo>/useful-mcps/mermaid", // Path to the MCP directory
"--",
"mermaid_mcp" // Match the script name defined in pyproject.toml
],
"env": { // Environment variables needed by the MCP
"MERMAID_CHART_ACCESS_TOKEN": "YOUR_API_TOKEN_HERE"
}
}
}
(참고: Mermaid Chart API 액세스 토큰을 환경 변수로 설정해야 합니다.)
날짜 필터링을 통해 RSS 피드 콘텐츠를 마크다운 형식으로 변환하는 서버입니다.
도구:
- fetch_rss_to_markdown : RSS 피드를 가져오고, 날짜별로 기사를 필터링하고, 일치하는 기사를 마크다운 목록으로 포맷하여 반환합니다.
MCP 서버 구성:
"mcpServers": {
"mermaid": {
"name": "rss2md", // Optional friendly name
"command": "uv",
"args": [
"run",
"--directory", "<path/to/repo>/useful-mcps/rss2md", // Path to the MCP directory
"--",
"rss2md_mcp" // Match the script name defined in pyproject.toml
],
"env": { // Environment variables needed by the MCP
}
}
}
설치
- 저장소를 복제합니다.
git clone https://github.com/daltonnyx/useful-mcps.git # Replace with the actual repo URL if different
cd useful-mcps
uv
설치: uv
가 없다면 설치하세요:pip install uv
# or follow instructions at https://github.com/astral-sh/uv
- 종속성: 종속성은
pyproject.toml
통해 MCP별로 관리됩니다. uv run
일반적으로 --directory
사용하여 처음으로 MCP를 실행할 때 가상 환경에 종속성을 자동으로 설치합니다.
용법
서버 실행
각 MCP 서버를 uv run --directory <path>
사용하여 특정 MCP 디렉토리를 가리키도록 실행하는 것이 좋습니다. uv
해당 디렉토리에 있는 pyproject.toml
을 기반으로 가상 환경과 종속성을 처리합니다.
예(루트 useful-mcps
디렉토리에서):
# Run the YouTube MCP
uv run --directory ./ytdlp ytdlp_mcp
# Run the Mermaid MCP (ensure token is set in environment)
uv run --directory ./mermaid mermaid_mcp
또는 MCP 클라이언트를 구성하여(위의 JSON 구성 예시처럼) uv run --directory ...
명령을 직접 실행하도록 합니다.
서버에 연결
각 서버의 "MCP 서버 구성" 예시에 나와 있는 command
및 args
구조를 사용하여 원하는 서버를 실행하도록 MCP 클라이언트 애플리케이션을 구성하세요. command
이 uv
실행 파일을 가리키고 args
MCP 폴더 경로와 실행할 스크립트 이름을 포함하는 --directory
올바르게 지정했는지 확인하세요. env
속성을 사용하여 필요한 환경 변수(API 토큰 등)를 전달하세요.
도구별 사용 예
이는 해당 MCP 서버의 call_tool
함수에 보낼 arguments
예를 보여줍니다.
YouTube 데이터 추출기
챕터 추출
{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
자막 추출
{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"language": "en",
"chapters": [
{
"title": "Introduction",
"start_time": "00:00:00",
"end_time": "00:01:30"
}
]
}
워드 문서 프로세서
프로세스 템플릿
{
"template_file": "/path/to/template.docx",
"replacements": {
"name": "John Doe",
"date": "2023-05-15"
},
"blocks": {
"optional_section": true,
"alternative_section": false
},
"output_filename": "/path/to/output.docx"
}
(참고: template_file
및 docx_file
경로 대신 base64로 인코딩된 문자열도 허용할 수 있습니다)
템플릿 키 가져오기
{
"template_file": "/path/to/template.docx"
}
PDF로 변환
{
"docx_file": "/path/to/document.docx",
"pdf_output": "/path/to/output.pdf"
}
PlantUML 렌더러
렌더 다이어그램
{
"input": "participant User\nUser -> Server: Request\nServer --> User: Response",
"output_path": "/path/to/save/diagram.png"
}
(참고: input
.puml
파일 경로일 수도 있습니다)
인어 렌더러
인어 차트 렌더링
{
"mermaid_code": "graph TD;\n A-->B;\n A-->C;\n B-->D;\n C-->D;",
"output_path": "/path/to/save/mermaid.png",
"theme": "default" // Optional, e.g., "default", "dark", "neutral", "forest"
}
개발
새 MCP 서버 추가
- MCP에 대한 새 디렉토리를 만듭니다(예:
my_new_mcp
). - 디렉토리 내부에 다음을 생성합니다.
pyproject.toml
: 프로젝트 메타데이터, 종속성 및 스크립트 진입점을 정의합니다(예: [project.scripts]
섹션 매핑 my_new_mcp = "my_new_mcp:main"
).pyrightconfig.json
: (선택 사항) 유형 검사를 위해 사용됩니다.- 주요 Python 파일(예:
my_new_mcp.py
): mcp
라이브러리를 사용하여 MCP 로직을 구현합니다(아래 템플릿 참조).
- 필요한 클래스와 함수(
serve
, list_tools
, call_tool
)를 구현합니다.
기본 템플릿( my_new_mcp.py
):
import json
import logging
import asyncio
from typing import List, Dict, Any, Optional
# Assuming mcp library is installed or available
# from mcp import Server, Tool, TextContent, stdio_server
# Placeholder imports if mcp library structure is different
from typing import Protocol # Using Protocol as placeholder
# Placeholder definitions if mcp library isn't directly importable here
class Tool(Protocol):
name: str
description: str
inputSchema: dict
class TextContent(Protocol):
type: str
text: str
class Server:
def __init__(self, name: str): pass
def list_tools(self): pass # Decorator
def call_tool(self): pass # Decorator
def create_initialization_options(self): pass
async def run(self, read_stream, write_stream, options): pass
# Placeholder context manager
class stdio_server:
async def __aenter__(self): return (None, None) # Dummy streams
async def __aexit__(self, exc_type, exc, tb): pass
# Pydantic is often used for schema definition
# from pydantic import BaseModel
# class MyInput(BaseModel):
# param1: str
# param2: int
class MyInputSchema: # Placeholder if not using Pydantic
@staticmethod
def model_json_schema():
return {"type": "object", "properties": {"param1": {"type": "string"}, "param2": {"type": "integer"}}, "required": ["param1", "param2"]}
class MyTools:
TOOL_NAME = "my.tool"
class MyService:
def __init__(self):
# Initialize resources if needed
pass
def my_function(self, param1: str, param2: int) -> dict:
# Implement your tool functionality
logging.info(f"Running my_function with {param1=}, {param2=}")
# Replace with actual logic
result_content = f"Result: processed {param1} and {param2}"
return {"content": result_content}
async def serve() -> None:
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
server = Server("mcp-my-service")
service = MyService()
@server.list_tools()
async def list_tools() -> list[Tool]:
logging.info("list_tools called")
return [
Tool(
name=MyTools.TOOL_NAME,
description="Description of my tool",
# Use Pydantic's schema or manually define
inputSchema=MyInputSchema.model_json_schema(),
),
]
@server.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
logging.info(f"call_tool called with {name=}, {arguments=}")
try:
if name == MyTools.TOOL_NAME:
# Add validation here if not using Pydantic
param1 = arguments.get("param1")
param2 = arguments.get("param2")
if param1 is None or param2 is None:
raise ValueError("Missing required arguments")
result = service.my_function(param1, int(param2)) # Ensure type conversion if needed
logging.info(f"Tool executed successfully: {result=}")
return [TextContent(type="text", text=json.dumps(result))] # Return JSON string
else:
logging.warning(f"Unknown tool requested: {name}")
raise ValueError(f"Unknown tool: {name}")
except Exception as e:
logging.error(f"Error executing tool {name}: {e}", exc_info=True)
# Return error as JSON
error_payload = json.dumps({"error": str(e)})
return [TextContent(type="text", text=error_payload)]
options = server.create_initialization_options()
logging.info("Starting MCP server...")
async with stdio_server() as (read_stream, write_stream):
await server.run(read_stream, write_stream, options)
logging.info("MCP server stopped.")
def main():
# Entry point defined in pyproject.toml `[project.scripts]`
try:
asyncio.run(serve())
except KeyboardInterrupt:
logging.info("Server interrupted by user.")
if __name__ == "__main__":
# Allows running directly via `python my_new_mcp.py` for debugging
main()
테스트
루트 디렉토리에서 pytest를 사용하여 테스트를 실행합니다.
(테스트 종속성이 설치되어 있는지 확인하세요. uv pip install pytest
사용하거나 pyproject.toml
파일 중 하나에 있는 개발 종속성에 pytest
추가하면 됩니다.)
특허
MIT 라이센스
기여하다
기여를 환영합니다! 풀 리퀘스트를 제출해 주세요.