Metadata-Version: 2.5
Name: machine-internet
Version: 0.1.0
Summary: Turn any website into an MCP server. No API needed.
Project-URL: Homepage, https://github.com/chetanty/machine_internet
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-agents,api,claude,mcp,model-context-protocol,openapi,scraping
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: anthropic>=2.8.0
Requires-Dist: click>=8.1.7
Requires-Dist: google-genai>=0.5.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp<2,>=1.27
Requires-Dist: openai>=1.0.0
Requires-Dist: playwright>=1.44.0
Requires-Dist: pydantic-settings>=2.3.0
Requires-Dist: pydantic>=2.7.0
Requires-Dist: pyyaml>=6.0.1
Requires-Dist: uvicorn>=0.30.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.2.0; extra == 'dev'
Description-Content-Type: text/markdown

# Machine Internet

**Turn any website into an MCP server. No API needed.**

```bash
uvx machine-internet wrap https://bundlephobia.com/package/react
```

Machine Internet opens the site in a headless browser, watches the hidden API calls the page makes, and turns them into a small set of clean tools that Claude, Cursor or any MCP client can call directly.

![Demo: wrapping bundlephobia.com and calling the new tool](assets/demo.gif)

[![CI](https://github.com/chetanty/machine_internet/actions/workflows/ci.yml/badge.svg)](https://github.com/chetanty/machine_internet/actions/workflows/ci.yml)
![License](https://img.shields.io/badge/license-Apache%202.0-blue)
![Python](https://img.shields.io/badge/python-3.10%2B-blue)
![MCP](https://img.shields.io/badge/MCP-compatible-orange)

---

## Try it in 30 seconds (no API key)

Ten sites come pre-wrapped, most with no public API. Add one to your Claude Desktop or Cursor config:

```json
{
  "mcpServers": {
    "bundlephobia": {
      "command": "uvx",
      "args": ["machine-internet", "serve", "bundlephobia"]
    }
  }
}
```

Restart your client and ask: *"How big is react-dom gzipped, and is lodash-es tree-shakeable?"*

| Example | Site | Tools |
|---|---|---|
| `bundlephobia` | [bundlephobia.com](https://bundlephobia.com) | 6: package size, tree-shaking check, size history, similar packages, per-export sizes, recent |
| `caniuse` | [caniuse.com](https://caniuse.com) | 4: search features, browser support data, feature details, news |
| `npm_trends` | [npmtrends.com](https://npmtrends.com) | 4: package info, weekly downloads, download trends, GitHub stats |
| `deps_dev` | [deps.dev](https://deps.dev) | 7: versions, dependencies, dependency graph, dependents, requirements, stats |
| `crates_io` | [crates.io](https://crates.io) | 6: search crates, crate info, versions, version details, stats, summary |
| `huggingface` | [huggingface.co](https://huggingface.co) | 1: search models, datasets and Spaces |
| `hacker_news` | [hn.algolia.com](https://hn.algolia.com) | 1: full-text search of HN stories and comments |
| `archive_org` | [archive.org](https://archive.org) | 3: search the archive, item metadata, item favorites |
| `ossinsight` | [ossinsight.io](https://ossinsight.io) | 2: search GitHub repos, users and orgs, live GitHub event stats |
| `regex101` | [regex101.com](https://regex101.com) | 3: browse the community library, get a saved regex, list versions |

You need [uv](https://docs.astral.sh/uv/) for `uvx`. Or install it once with `pip install machine-internet` (or straight from GitHub: `pip install git+https://github.com/chetanty/machine_internet`) and use `machine-internet` as the command.

**Hosted, nothing to install:** every example is also live at [machine-internet.vercel.app](https://machine-internet.vercel.app) as a remote MCP endpoint, e.g. `https://machine-internet.vercel.app/mcp/bundlephobia`. Clients with remote MCP support take the URL directly; others can use `npx mcp-remote <url>`. Some sites rate-limit requests from cloud servers (npm's download stats do), so for heavy use run `serve` locally, which calls the site from your own connection.

---

## Wrap your own site

Set an LLM key (any one of these works):

```bash
export ANTHROPIC_API_KEY=...   # or OPENAI_API_KEY, or GEMINI_API_KEY
```

Then point it at a page that loads data as you use it:

```bash
uvx machine-internet wrap https://bundlephobia.com/package/react
```

```
Wrapping https://bundlephobia.com/package/react
  Checking for an OpenAPI spec ...
  Sniffing network traffic in a headless browser ...
  [OK] Inferred 4 endpoints
  Condensing into agent tools ...
  [OK] 4 tools:
       get_package_size: Use this tool to get detailed size information for a JavaScript packag
       get_package_history: Use this tool to retrieve the historical versions of a specific JavaSc
       ...

Add this to your MCP client config (Claude Desktop, Cursor, ...):
{ "mcpServers": { "bundlephobia_api": { "command": "uvx", "args": ["machine-internet", "serve", "bundlephobia_api"] } } }
```

The first run downloads headless Chromium once (about 150 MB). Wrapping takes 1 to 3 minutes and costs a few cents of LLM usage. Serving afterwards needs no LLM at all.

**Tips**
- Pick a page that fetches data: a search results page or an item page works better than a static landing page.
- If the site publishes an OpenAPI spec, it is used automatically and nothing is sniffed. Point at one directly with `--spec <url>`.
- Large specs: keep only some areas with `--tags repos,issues`.

---

## How it works

1. **Spec check.** Probes about 20 standard locations (`/openapi.json`, `/swagger.json`, ...). If a real spec exists, it is parsed directly.
2. **Traffic sniffing.** Otherwise, launches headless Chromium, loads the page, scrolls and clicks through it, and records every same-site JSON request. Analytics and ad trackers are filtered out.
3. **Inference.** An LLM reads the captured requests and responses and infers each endpoint's path, parameters and types.
4. **Condensation.** An LLM collapses the endpoints into at most 15 `verb_noun` tools, with descriptions written so an agent knows when to use each one.
5. **Serving.** The result is a small JSON file. `machine-internet serve` exposes it as a standard MCP server (stdio by default, SSE with `--sse`) that makes real calls to the real site.

---

## Commands

```bash
machine-internet wrap <url> [--name NAME] [--spec URL] [--tags a,b] [--sniff] [-o FILE]
machine-internet serve <name-or-file.json> [--sse --port 8000]
machine-internet list                  # bundled examples and servers you have wrapped
machine-internet tools <name>          # show a server's tools and parameters
machine-internet call <name> <tool> key=value ...   # call a tool from the terminal
machine-internet config <name>         # print the MCP client config block
```

Wrapped servers are saved to `~/.machine-internet/schemas/`.

**APIs that need auth:** credentials are read from the environment when the server runs: `MI_TOKEN` (bearer), `MI_API_KEY` (plus `MI_API_KEY_NAME`, `MI_API_KEY_IN=header|query`), `MI_USERNAME` / `MI_PASSWORD`, or `MI_TOKEN_URL` / `MI_CLIENT_ID` / `MI_CLIENT_SECRET` for OAuth2 client credentials. Put them in the `env` block of your MCP client config.

---

## What it works on

It works on sites whose pages load their data with API calls from the browser: most single-page apps, search pages, dashboards and developer tools. It does not work on sites that render pages on the server, or that block headless browsers.

Results from pointing `wrap` at 15 popular sites, with each generated tool then called for real:

| Result | Sites |
|---|---|
| Works | crates.io, deps.dev, Hugging Face, archive.org, HN Search (Algolia), OSS Insight |
| Partly works | Open Library (1 of 2 tools) |
| No hidden API found (server-rendered) | IMDb, Reddit, GitHub Trending, npmjs.com |
| Blocked or only trackers seen | Product Hunt, lichess, packagephobia |
| Nothing useful captured | dev.to (only a session-token call) |

So roughly half of the arbitrary sites tried. When it fails, it says why and suggests a page that is more likely to work.

## Limitations

- **Internal APIs change without notice.** A wrapped site can break when it ships a new frontend. Re-run `wrap` to refresh it.
- **It only sees what the page does while loading and being clicked.** Actions behind logins, multi-step forms or heavy anti-bot protection usually are not captured.
- **LLM output varies.** If the tools look wrong, run `wrap` again or narrow the page you point it at.

## Use responsibly

Undocumented APIs are still someone else's service. Check the site's terms before wrapping it, keep request volume reasonable, and do not use this to get around access controls or rate limits.

---

## How it compares

| | Machine Internet | OpenAPI-to-MCP converters | Browser agents |
|---|---|---|---|
| Works without an API spec | Yes | No | Yes |
| Agent calls the API directly (fast, cheap per call) | Yes | Yes | No, drives a browser every time |
| One command from URL to MCP server | Yes | Needs a spec | No |

Related work worth knowing: [Integuru](https://github.com/Integuru-AI/Integuru) generates integration code from captured traffic, and [mitmproxy2swagger](https://github.com/alufers/mitmproxy2swagger) builds OpenAPI specs from recorded traffic. Machine Internet's focus is going straight from a URL to a running MCP server.

---

## Development

```bash
git clone https://github.com/chetanty/machine_internet
cd machine_internet
pip install -e ".[dev]"
pytest
python evals/score.py      # condensation quality evals (needs an LLM key)
```

## License

Apache 2.0
