Skip to main content
Glama

URL Text Fetcher MCP Server

mcp_server.py1.18 kB
from mcp.server.fastmcp import FastMCP import requests from bs4 import BeautifulSoup from typing import List import asyncio import sys mcp = FastMCP("URL Text Fetcher") @mcp.tool() def fetch_url_text(url: str) -> str: """Download all visible text from a URL.""" resp = requests.get(url, timeout=10) resp.raise_for_status() soup = BeautifulSoup(resp.text, "html.parser") return soup.get_text(separator="\n", strip=True) @mcp.tool() def fetch_page_links(url: str) -> List[str]: """Return a list of all links on the page.""" resp = requests.get(url, timeout=10) resp.raise_for_status() soup = BeautifulSoup(resp.text, "html.parser") return [a['href'] for a in soup.find_all('a', href=True)] def main(): # Note: Write startup/shutdown messages to stderr to avoid corrupting MCP stdio JSON-RPC on stdout sys.stderr.write("MCP Server started for LM Studio...\n") sys.stderr.flush() try: mcp.run() return 0 except (KeyboardInterrupt, asyncio.CancelledError): return 0 finally: sys.stderr.write("Server Stopped\n") sys.stderr.flush() if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alexandru2882/url-text-fetcher-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server