URL Fetch MCP

by aelaguiz
Verified

hybrid server

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

Integrations

  • Uses Pydantic for type validation of URL parameters and request configuration

URL 가져오기 MCP

Claude나 LLM이 URL에서 콘텐츠를 가져올 수 있도록 하는 깔끔한 MCP(Model Context Protocol) 구현입니다.

특징

  • 모든 URL에서 콘텐츠 가져오기
  • 다양한 콘텐츠 유형(HTML, JSON, 텍스트, 이미지) 지원
  • 요청 매개변수(헤더, 시간 초과) 제어
  • 깔끔한 오류 처리
  • Claude Code와 Claude Desktop 모두에서 작동합니다.

저장소 구조

지엑스피1

설치

# Install from source pip install -e . # Install with development dependencies pip install -e ".[dev]"

용법

서버 실행

# Run with stdio transport (for Claude Code) python -m url_fetch_mcp run # Run with HTTP+SSE transport (for remote connections) python -m url_fetch_mcp run --transport sse --port 8000

Claude Desktop에 설치

Claude Desktop을 설치하는 방법은 세 가지가 있습니다.

방법 1: 직접 설치

# Install the package pip install -e . # Install in Claude Desktop using the included script mcp install url_fetcher.py -n "URL Fetcher"

url_fetcher.py 파일에는 다음이 포함되어 있습니다.

#!/usr/bin/env python """ URL Fetcher MCP Server This is a standalone script for launching the URL Fetch MCP server. It's used for installing in Claude Desktop with the command: mcp install url_fetcher.py -n "URL Fetcher" """ from url_fetch_mcp.main import app if __name__ == "__main__": app.run()

방법 2: 설치 프로그램 스크립트 사용

# Install the package pip install -e . # Run the installer script python scripts/install_desktop.py

scripts/install_desktop.py 스크립트:

#!/usr/bin/env python import os import sys import tempfile import subprocess def install_desktop(): """Install URL Fetch MCP in Claude Desktop.""" print("Installing URL Fetch MCP in Claude Desktop...") # Create a temporary Python file that imports our module temp_dir = tempfile.mkdtemp() temp_file = os.path.join(temp_dir, "url_fetcher.py") with open(temp_file, "w") as f: f.write("""#!/usr/bin/env python # URL Fetcher MCP Server from url_fetch_mcp.main import app if __name__ == "__main__": app.run() """) # Make the file executable os.chmod(temp_file, 0o755) # Run the mcp install command with the file path try: cmd = ["mcp", "install", temp_file, "-n", "URL Fetcher"] print(f"Running: {' '.join(cmd)}") result = subprocess.run(cmd, check=True, text=True) print("Installation successful!") print("You can now use the URL Fetcher tool in Claude Desktop.") return 0 except subprocess.CalledProcessError as e: print(f"Error during installation: {str(e)}") return 1 finally: # Clean up temporary file try: os.unlink(temp_file) os.rmdir(temp_dir) except: pass if __name__ == "__main__": sys.exit(install_desktop())

방법 3: CLI 명령 사용

# Install the package pip install -e . # Install using the built-in CLI command python -m url_fetch_mcp install-desktop

핵심 구현

주요 MCP 구현은 src/url_fetch_mcp/main.py 에 있습니다.

from typing import Annotated, Dict, Optional import base64 import json import httpx from pydantic import AnyUrl, Field from mcp.server.fastmcp import FastMCP, Context # Create the MCP server app = FastMCP( name="URL Fetcher", version="0.1.0", description="A clean MCP implementation for fetching content from URLs", ) @app.tool() async def fetch_url( url: Annotated[AnyUrl, Field(description="The URL to fetch")], headers: Annotated[ Optional[Dict[str, str]], Field(description="Additional headers to send with the request") ] = None, timeout: Annotated[int, Field(description="Request timeout in seconds")] = 10, ctx: Context = None, ) -> str: """Fetch content from a URL and return it as text.""" # Implementation details... @app.tool() async def fetch_image( url: Annotated[AnyUrl, Field(description="The URL to fetch the image from")], timeout: Annotated[int, Field(description="Request timeout in seconds")] = 10, ctx: Context = None, ) -> Dict: """Fetch an image from a URL and return it as an image.""" # Implementation details... @app.tool() async def fetch_json( url: Annotated[AnyUrl, Field(description="The URL to fetch JSON from")], headers: Annotated[ Optional[Dict[str, str]], Field(description="Additional headers to send with the request") ] = None, timeout: Annotated[int, Field(description="Request timeout in seconds")] = 10, ctx: Context = None, ) -> str: """Fetch JSON from a URL, parse it, and return it formatted.""" # Implementation details...

도구 기능

페치_URL

URL에서 콘텐츠를 가져와 텍스트로 반환합니다.

매개변수:

  • url (필수): 가져올 URL
  • headers (선택 사항): 요청과 함께 보낼 추가 헤더
  • timeout (선택 사항): 요청 시간 초과(초)(기본값: 10)

페치_이미지

URL에서 이미지를 가져와 이미지로 반환합니다.

매개변수:

  • url (필수): 이미지를 가져올 URL
  • timeout (선택 사항): 요청 시간 초과(초)(기본값: 10)

페치_제이슨

URL에서 JSON을 가져와서 구문 분석하고 포맷된 형태로 반환합니다.

매개변수:

  • url (필수): JSON을 가져올 URL
  • headers (선택 사항): 요청과 함께 보낼 추가 헤더
  • timeout (선택 사항): 요청 시간 초과(초)(기본값: 10)

예시

examples 디렉토리에는 예제 스크립트가 포함되어 있습니다.

  • quick_test.py : MCP 서버의 빠른 테스트
  • simple_usage.py : 클라이언트 API 사용 예
  • interactive_client.py : 테스트를 위한 대화형 CLI
# Example of fetching a URL result = await session.call_tool("fetch_url", { "url": "https://example.com" }) # Example of fetching JSON data result = await session.call_tool("fetch_json", { "url": "https://api.example.com/data", "headers": {"Authorization": "Bearer token"} }) # Example of fetching an image result = await session.call_tool("fetch_image", { "url": "https://example.com/image.jpg" })

테스트

기본 기능을 테스트하려면:

# Run a direct test of URL fetching python direct_test.py # Run a simplified test with the MCP server python examples/quick_test.py

특허

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

Claude나 다른 LLM이 URL에서 콘텐츠를 가져올 수 있도록 하는 MCP(Model Context Protocol) 서버로, 구성 가능한 요청 매개변수를 통해 HTML, JSON, 텍스트 및 이미지를 지원합니다.

  1. Features
    1. Repository Structure
      1. Installation
        1. Usage
          1. Running the Server
          2. Installing in Claude Desktop
        2. Core Implementation
          1. Tool Capabilities
            1. fetch_url
            2. fetch_image
            3. fetch_json
          2. Examples
            1. Testing
              1. License

                Appeared in Searches

                ID: a7rjk6pfj7