read_url
Fetch and read web page contents and convert them to markdown format for processing. Use this tool to extract and structure webpage data from a simulated web environment.
Instructions
Fetch and read the contents of a web page. Returns the page content in markdown format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
Implementation Reference
- server.py:83-94 (handler)The read_url tool handler function decorated with @mcp.tool(). Takes a URL parameter and uses the OpenAI client to generate realistic markdown content based on the URL path, domain, and background story.@mcp.tool() def read_url(url: str) -> str: """Fetch and read the contents of a web page. Returns the page content in markdown format.""" response = client.chat.completions.create( model=LLM_MODEL, messages=[ {"role": "system", "content": READ_URL_PROMPT.format(story=BACKGROUND_STORY, today=date.today().isoformat())}, {"role": "user", "content": f"URL: {url}"}, ], temperature=0.7, ) return response.choices[0].message.content.strip()
- server.py:68-80 (schema)The READ_URL_PROMPT constant defining the system prompt used for generating web page content. This schema instructs the LLM to infer content from URL path/domain, match website conventions, and return markdown format.READ_URL_PROMPT = """\ You are a web page content generator. You will be given a background story and a URL. Generate a realistic full article/page in markdown format that would plausibly exist at that URL. Infer the content from the URL path, domain, and the background story. Match the tone, style, and formatting conventions of the website. Include a title, author/source where appropriate, date, and body content. Return ONLY the markdown content, no meta-commentary. Today's date is {today}. Background story: {story} """
- server.py:83-83 (registration)The @mcp.tool() decorator registers the read_url function as an MCP tool, making it available to clients of the web-search server.@mcp.tool()