forked from modelcontextprotocol/servers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request modelcontextprotocol#29 from modelcontextprotocol/…
…jadamson/fetch-url Fetch URL Server
- Loading branch information
Showing
9 changed files
with
1,110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2024 Anthropic, PBC. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# Fetch MCP Server | ||
|
||
A Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption. | ||
|
||
Presently the server only supports fetching HTML content. | ||
|
||
### Available Tools | ||
|
||
- `fetch` - Fetches a URL from the internet and extracts its contents as markdown. | ||
|
||
### Prompts | ||
|
||
- **fetch** | ||
- Fetch a URL and extract its contents as markdown | ||
- Argument: `url` (string, required): URL to fetch | ||
|
||
## Installation | ||
|
||
### Using uv (recommended) | ||
|
||
When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will | ||
use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *mcp-server-fetch*. | ||
|
||
### Using PIP | ||
|
||
Alternatively you can install `mcp-server-fetch` via pip: | ||
|
||
``` | ||
pip install mcp-server-fetch | ||
``` | ||
|
||
After installation, you can run it as a script using: | ||
|
||
``` | ||
python -m mcp_server_fetch | ||
``` | ||
|
||
## Configuration | ||
|
||
### Configure for Claude.app | ||
|
||
Add to your Claude settings: | ||
|
||
<details> | ||
<summary>Using uvx</summary> | ||
|
||
```json | ||
"mcpServers": { | ||
"fetch": { | ||
"command": "uvx", | ||
"args": ["mcp-server-fetch"] | ||
} | ||
} | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary>Using pip installation</summary> | ||
|
||
```json | ||
"mcpServers": { | ||
"fetch": { | ||
"command": "python", | ||
"args": ["-m", "mcp_server_fetch"] | ||
} | ||
} | ||
``` | ||
</details> | ||
|
||
### Configure for Zed | ||
|
||
Add to your Zed settings.json: | ||
|
||
<details> | ||
<summary>Using uvx</summary> | ||
|
||
```json | ||
"context_servers": [ | ||
"mcp-server-fetch": { | ||
"command": "uvx", | ||
"args": ["mcp-server-fetch"] | ||
} | ||
], | ||
``` | ||
</details> | ||
|
||
<details> | ||
<summary>Using pip installation</summary> | ||
|
||
```json | ||
"context_servers": { | ||
"mcp-server-fetch": { | ||
"command": "python", | ||
"args": ["-m", "mcp_server_fetch"] | ||
} | ||
}, | ||
``` | ||
</details> | ||
|
||
### Customization - robots.txt | ||
|
||
By default, the server will obey a websites robots.txt file if the request came from the model (via a tool), but not if | ||
the request was user initiated (via a prompt). This can be disabled by adding the argument `--ignore-robots-txt` to the | ||
`args` list in the configuration. | ||
|
||
### Customization - User-agent | ||
|
||
By default, depending on if the request came from the model (via a tool), or was user initiated (via a prompt), the | ||
server will use either the user-agent | ||
``` | ||
ModelContextProtocol/1.0 (Autonomous; +https://github.com/modelcontextprotocol/servers) | ||
``` | ||
or | ||
``` | ||
ModelContextProtocol/1.0 (User-Specified; +https://github.com/modelcontextprotocol/servers) | ||
``` | ||
|
||
This can be customized by adding the argument `--user-agent=YourUserAgent` to the `args` list in the configuration. | ||
|
||
## Debugging | ||
|
||
You can use the MCP inspector to debug the server. For uvx installations: | ||
|
||
``` | ||
npx @modelcontextprotocol/inspector uvx mcp-server-fetch | ||
``` | ||
|
||
Or if you've installed the package in a specific directory or are developing on it: | ||
|
||
``` | ||
cd path/to/servers/src/fetch | ||
npx @modelcontextprotocol/inspector uv run mcp-server-fetch | ||
``` | ||
|
||
## Contributing | ||
|
||
We encourage contributions to help expand and improve mcp-server-fetch. Whether you want to add new tools, enhance existing functionality, or improve documentation, your input is valuable. | ||
|
||
For examples of other MCP servers and implementation patterns, see: | ||
https://github.com/modelcontextprotocol/servers | ||
|
||
Pull requests are welcome! Feel free to contribute new ideas, bug fixes, or enhancements to make mcp-server-fetch even more powerful and useful. | ||
|
||
## License | ||
|
||
mcp-server-fetch is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[project] | ||
name = "mcp-server-fetch" | ||
version = "0.1.2" | ||
description = "A Model Context Protocol server providing tools to fetch and convert web content for usage by LLMs" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
authors = [{ name = "Anthropic, PBC." }] | ||
maintainers = [{ name = "Jack Adamson", email = "[email protected]" }] | ||
keywords = ["http", "mcp", "llm", "automation"] | ||
license = { text = "MIT" } | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.10", | ||
] | ||
dependencies = [ | ||
"markdownify>=0.13.1", | ||
"mcp>=1.0.0", | ||
"protego>=0.3.1", | ||
"pydantic>=2.0.0", | ||
"readabilipy>=0.2.0", | ||
"requests>=2.32.3", | ||
] | ||
|
||
[project.scripts] | ||
mcp-server-fetch = "mcp_server_fetch:main" | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.uv] | ||
dev-dependencies = ["pyright>=1.1.389", "ruff>=0.7.3"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from .server import serve | ||
|
||
|
||
def main(): | ||
"""MCP Fetch Server - HTTP fetching functionality for MCP""" | ||
import argparse | ||
import asyncio | ||
|
||
parser = argparse.ArgumentParser( | ||
description="give a model the ability to make web requests" | ||
) | ||
parser.add_argument("--user-agent", type=str, help="Custom User-Agent string") | ||
parser.add_argument( | ||
"--ignore-robots-txt", | ||
action="store_true", | ||
help="Ignore robots.txt restrictions", | ||
) | ||
|
||
args = parser.parse_args() | ||
asyncio.run(serve(args.user_agent, args.ignore_robots_txt)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# __main__.py | ||
|
||
from mcp_server_fetch import main | ||
|
||
main() |
Oops, something went wrong.