Skip to main content
Glama
Underc0de MCP
by Ximeeek
README.md
# Underc0de MCP

[![CI](https://github.com/Ximeeek/underc0de-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Ximeeek/underc0de-mcp/actions/workflows/ci.yml)

[Polski](README.pl.md) · [Access research](docs/access-research.md) · [Feature rationale](docs/feature-research.md)

A read-only Model Context Protocol server for researching the public Underc0de forum. TypeScript, Node.js 22+, stdio transport, structured results and exact source citations. Forum content is read live; there is no local post database or scheduled crawler.

**Verified on 2026-12-06:** a real child-process stdio MCP client successfully discovered 75 public boards and read topic listings, native pagination, exact posts, content continuations, references, bounded title-search results and RSS through an explicitly attached Thorium session. Native guest full-text search requires a separate human verification and returns `SEARCH_VERIFICATION_REQUIRED`; title search remains available. Direct HTTP and initial fresh managed-browser probes received Cloudflare challenges. See the [live validation report](docs/live-validation.json), [access evidence](docs/access-research.md) and [feature research](docs/feature-research.md).

This is an independent client, not an official Underc0de integration. It does not need an API key or OAuth token. That does not guarantee that every guest page or native search is accessible without a session.

**Latest reliability follow-up:** 163 offline tests pass. Current live acceptance is blocked because the configured local browser endpoint is unavailable (`BROWSER_NOT_ATTACHABLE`); earlier successful content reads remain historical evidence. See the [follow-up report](docs/session-reliability-validation.json) and [session research](docs/session-reliability.md).

## Install

Requirements: Node.js 22 or newer and npm. The default browser engine additionally needs a normal installed Google Chrome or Microsoft Edge. `playwright-core` drives that browser; this project does not download a browser distribution. An optional, separately provisioned Camoufox engine is described below.

```sh
git clone https://github.com/Ximeeek/underc0de-mcp.git
cd underc0de-mcp
npm ci
npm run build
node dist/cli.js doctor
```

The GitHub source is the installation route. This project has not been published to npm; do not assume that an identically named registry package belongs to this repository.

## Connect an MCP client

Use a direct Node invocation and an absolute path to your checkout. The example below uses the observed working access path: an existing local Chromium-family browser that you have deliberately started with a loopback debugging port, as described in the attachment section below:

```json
{
  "mcpServers": {
    "underc0de": {
      "command": "node",
      "args": ["/absolute/path/to/underc0de-mcp/dist/cli.js", "serve"],
      "env": {
        "UNDERC0DE_TRANSPORT": "browser",
        "UNDERC0DE_CDP_ENDPOINT": "http://127.0.0.1:9222",
        "UNDERC0DE_BROWSER_FETCH": "true",
        "UNDERC0DE_REQUEST_INTERVAL_MS": "1500"
      }
    }
  }
}
```

On Windows, forward slashes in the JSON path avoid backslash escaping. See [mcp.example.json](mcp.example.json). Machine-specific `*.local.json` files are ignored by Git. No global MCP client configuration is changed by installing or building this project.

`serve` is the default command. Protocol output uses stdout; diagnostics use stderr. The server does not open an HTTP endpoint or require a hosted service.

## Access and browser verification

`UNDERC0DE_TRANSPORT` selects the access path:

| Value | Behavior |
| --- | --- |
| `auto` — default | Try bounded HTTP reads; if the site challenges that path, use the normal browser session. |
| `http` | Use direct anonymous HTTP only. A challenge remains an explicit error. |
| `browser` | Use the installed Chrome/Edge session for supported forum reads. |

Without either attachment setting, managed Chromium mode uses a dedicated profile under `~/.underc0de-mcp/chrome-profile`, separate from your everyday browser profile. Explicit attachment instead connects to the already running browser you selected; it does not create or copy that personal profile. Cookies remain in that browser profile and are not exported to a JSON cookie jar. The profile is sensitive local state: do not publish it, share it or place the data directory inside a tracked repository.

For a **managed dedicated browser** that requires a human check, run:

```sh
node dist/cli.js auth
```

This opens a visible browser for normal manual verification and keeps it available for the server to reuse. Complete the site's requested step there, then press **Ctrl+C** to release the session lock before running `check` or connecting MCP. The dedicated Chromium browser can remain open for reuse. Then verify the connection:

```sh
node dist/cli.js check
```

Do not run a new independent browser against an already locked profile. Use `session_status` to inspect the session and `close_session` when you deliberately want to close a managed session or detach an attached one. `open_session` can open the supported forum session from an MCP client. The CLI `node dist/cli.js close-session` can close a managed dedicated Chromium browser even after the MCP client has disconnected. When explicitly attached to a personal browser, it only detaches; that browser is never closed. These commands do not solve challenges automatically, bypass login, expose private boards or guarantee search permission. A timed-out or blocked verification must not be mistaken for successful access.

Browser sessions are headless by default and kept alive by default. `auth` selects a visible session. You can use `UNDERC0DE_HEADLESS=false` when a visible session is needed for a manual step.

## Attach an existing Thorium/Chromium session

Use this path when Underc0de already works in your normal browser. **The MCP never restarts or launches your personal browser.** Before restarting it yourself, save unfinished forms and work, select the tab/session restoration you want, and close the browser normally. An automated restart requires your explicit approval; attaching to a browser is not permission to restart it.

Then start that browser yourself with a local debugging listener. For example, in PowerShell, substitute the actual Thorium executable:

```powershell
& "C:/absolute/path/to/thorium.exe" --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 --restore-last-session
```

If an existing process absorbs the launch, the new flags may not take effect; quit it normally before the deliberate restart. Browser versions differ in whether they allow debugging their usual data directory. The attachment works only after the browser exposes a working endpoint. No profile is copied or silently substituted by the MCP.

Open `https://underc0de.org/foro/` normally in that browser and complete any ordinary site verification there. Configure `UNDERC0DE_TRANSPORT=browser` and `UNDERC0DE_CDP_ENDPOINT=http://127.0.0.1:9222`, then run `check` or connect MCP. No API key or exported cookie file is used.

The endpoint accepts only explicit `127.0.0.1` loopback HTTP or a validated local browser websocket. An HTTP value must be `http://127.0.0.1:PORT`; the server validates the returned browser websocket. An explicit `ws://127.0.0.1:PORT/devtools/browser/ID` is also supported. Credentials, query strings, fragments, nonlocal hosts and arbitrary CDP URL paths are rejected. Keep the debugging listener local.

Alternatively, set `UNDERC0DE_ATTACH_PROFILE_DIR` to the exact existing browser user-data directory containing `DevToolsActivePort`. This only discovers an already running browser's debugging endpoint. It does not copy cookies, launch the browser, or grant access to an unopened profile. Keep `UNDERC0DE_DATA_DIR` outside that personal directory so the MCP's own lock is separate. Use **either** `UNDERC0DE_CDP_ENDPOINT` **or** `UNDERC0DE_ATTACH_PROFILE_DIR`; both are incompatible with `UNDERC0DE_BROWSER_ENGINE=camoufox`.

`session_status` reports `browserOwnership: attached`. In this mode `close_session`, the `close-session` CLI command and process shutdown only detach the MCP connection. They never close, restart or replace the personal browser, regardless of `KEEP_BROWSER_ALIVE`. Cookies stay in the browser and are never exported or transferred between profiles.

`UNDERC0DE_BROWSER_FETCH=true` is the default: supported reads can use same-origin fetch from an already readable forum document, reusing its ordinary session. Actual response status and provenance remain in the result. Set it to `false` only if you deliberately prefer navigation of the selected forum tab. Route allowlisting remains enforced in both paths; neither is an arbitrary browser/URL control tool. Do not share the browser-control endpoint with other machines.

### Session reliability and renewed verification

The MCP preserves a pending verification across **all** requested read URLs, including `fresh=true`. Another queued tool does not reload or navigate away from that verification. After manual completion, a request for the same document can reuse it with its original navigation time; a request for another document still reads that actual URL. At attachment, the server examines at most eight supported forum tabs and prefers a readable one over an old challenge or HTTP error page. It does not inspect unrelated tab content.

Normal same-origin fetch and manual verification run without a persistent Playwright route handler. Redirect interception exists only while the MCP performs an explicit top-level navigation and is removed in `finally`, including errors. This avoids permanently disabling the selected tab's HTTP cache. `session_status` exposes `activity` counters, `challengeScope: session`, `navigationInterception: mcp_navigation_only` and `checkpointRestored` so repeated network reads can be distinguished from DOM or content-cache reuse.

An optional `session-checkpoint.json` under `UNDERC0DE_DATA_DIR` retains request timing, Retry-After, canonical public document URLs and response-status metadata. It contains no cookies, headers, form tokens or forum content. The browser endpoint is stored only as a SHA-256 identity; document status is restored only if both URL and `performance.timeOrigin` match. Reads are capped at 16 KiB; invalid or mismatched metadata are ignored. Atomic checkpoint failures do not prevent forum reads, and metadata observation is bounded to 500 ms. Checkpoints stay outside Git and package contents.

The site may require a new verification even after previous successful access. The client cannot extend the operator's clearance lifetime or promise that challenges never recur. Do not repeatedly retry a challenge, rotate profiles or replace a working browser session. For a durable machine interface, an operator-provided API or explicitly approved access policy is needed. See the [source-backed reliability investigation](docs/session-reliability.md) for the implementation differences and current validation limits.

## Optional Camoufox runtime

Camoufox is an optional engine, not a required dependency of the MCP. It did not clear Underc0de's challenge in the initial fresh-profile test; selecting it is not a promise of access and does not introduce a solver. The MCP does not configure proxy services, solve challenges or supply account credentials.

The checked `camoufox@0.5.9` package requires Node.js **22.15 or newer** and `playwright-core` **below 1.63**. Keep it in a separate runtime so its peer dependency does not conflict with the MCP's newer Playwright. Provision this runtime outside the repository:

```sh
mkdir /absolute/path/to/camoufox-runtime
cd /absolute/path/to/camoufox-runtime
npm init -y
npm install --save-exact camoufox@0.5.9 playwright-core@1.62.1
npx --no-install camoufox fetch
npx --no-install camoufox list installed --path
```

`fetch` deliberately installs the paired browser and model data before MCP starts. Select the real browser executable from the installed build, not the runtime package directory. Add these variables to the MCP client configuration, using actual absolute paths:

```json
{
  "UNDERC0DE_TRANSPORT": "browser",
  "UNDERC0DE_BROWSER_ENGINE": "camoufox",
  "UNDERC0DE_CAMOUFOX_RUNTIME_DIR": "/absolute/path/to/camoufox-runtime",
  "UNDERC0DE_CAMOUFOX_EXECUTABLE": "/absolute/path/to/the/installed/camoufox-executable",
  "UNDERC0DE_KEEP_BROWSER_ALIVE": "false"
}
```

Camoufox uses a separate `camoufox-profile` under the configured data directory. Its context closes when the server or `auth` process exits; the profile is retained. `UNDERC0DE_KEEP_BROWSER_ALIVE=true` is rejected for this engine. Use the same engine, data directory and provisioned runtime for `auth`, `check` and MCP. Manual verification is still manual, and a retained profile does not guarantee future access.

## Tools

The server exposes **14 tools**. All forum operations are bounded reads. Session tools control the local browser lifecycle and do not post, edit or message on the forum.

| Tool | Purpose |
| --- | --- |
| `forum_status` | Check actual access and report transport, pacing, cache and limitations. |
| `list_boards` | Discover live board names, identifiers and hierarchy. Optional relevance uses explicit editorial name matching. |
| `list_topics` | Read one board page with topic metadata and continuation. Last-reply time is not original publication time. |
| `search_board_titles` | Search titles on 1-3 pages of one live board; explicit non-exhaustive alternative when guest native search needs verification. |
| `search_forum` | Preflight the real native search form. Required guest verification returns `SEARCH_VERIFICATION_REQUIRED` before query submission and suggests `search_board_titles`. |
| `read_topic` | Read one topic page with message attribution, code, quotes and bounded content. |
| `read_post` | Read an exact message and recover long content through `contentOffset`. |
| `read_topics` | Compare at most three topic pages with separate provenance and errors. |
| `recent_posts` | Request a bounded recent RSS window; feed availability is checked rather than assumed. |
| `extract_references` | Extract inert links, media metadata and code attached to source messages. |
| `research_plan` | Produce an offline Spanish/English search plan, board-name hints and primary references. |
| `open_session` | Open a managed session or attach to the explicitly selected running browser. |
| `session_status` | Inspect access state and whether browser ownership is managed or attached. |
| `close_session` | Close a managed session; for an attached personal browser, detach only. |

Resource: `underc0de://research-guide`. Prompt: `research_topic`.

Tool discovery is authoritative for the current input schema. The planner does not run a search, infer a vulnerability or claim a board exists. Its curated board subset was observed in the native root DOM on 2026-12-06 and is explicitly dated. `discoveryRequired` remains true: confirm current identifiers, names and access with `list_boards` before using the proposed filters. Do not reuse IDs from a different forum. Priorities are editorial, not a forum-authority ranking.

## Research workflow

1. Check `forum_status`. If access is challenged, complete the manual browser step and check again.
2. Resolve live boards with `list_boards`; use `research_plan` for vocabulary, not discovered results.
3. Native guest search was observed to require a verification question/CAPTCHA. `search_forum` checks the actual form and stops with `SEARCH_VERIFICATION_REQUIRED` before sending a query when that requirement remains. Use `search_board_titles` on one confirmed board for a bounded title scan. Start with one page, preserve coverage and follow `nextBoardOffset` deliberately. This alternative does not search message bodies or the whole forum.
4. Read candidate messages with `read_topic` and `read_post`. Follow returned pagination/content offsets instead of assuming the first page is complete.
5. Compare contradictory replies with `read_topics`, and use `extract_references` to preserve the citation behind each link or code sample.
6. Cross-check versions, prerequisites and claimed impact with maintained OWASP, PortSwigger, MDN and vendor documentation. Keep forum observations, independently corroborated facts and untested hypotheses distinct.

The offline planner covers common web vulnerability families, API authorization, business logic/races, reconnaissance and reporting. See [feature research](docs/feature-research.md) for the rationale and primary references. It does not claim that every area is represented in the forum.

## Search limits: native verification and bounded titles

The real guest search form observed on 2026-12-06 contained a verification question/CAPTCHA (`search_vv[q][4]`). An ordinary operator search submission without verification returned validation errors. The server does not solve that step. `search_forum` first reads `action=search`; when verification is required it returns `SEARCH_VERIFICATION_REQUIRED`, with `suggestedTool: search_board_titles`, **before submitting any native query**. Reading the forum successfully does not imply permission to use native search.

The observed native form accepts at most **100 query characters**. `search_forum` accepts 3-100 characters and uses the actual sort values `id_msg` and `num_replies`; the form options were checked against the live site and official SMF sources. Query execution and sort behavior could not be validated past guest verification. The title-scan limit below is separate.

`search_board_titles` provides a deliberately narrower discovery tool:

```json
{
  "board": 205,
  "query": "XSS",
  "maxPages": 1,
  "maxResults": 30,
  "match": "all"
}
```

Board 205 was observed as Seguridad web y en servidores; confirm it with `list_boards` before reusing this example. Queries accept 2-200 characters and at most 16 whitespace-separated terms. Matching ignores case and accents and uses title substrings, with `all` or `any` terms. `maxPages` is 1-3, default 1; `maxResults` is 1-120, default 30. `start` is a native board offset, not a page number; `fresh` has the usual cache meaning.

The result method is `bounded_board_title_scan`. Its coverage explicitly reports `exhaustive: false`, `nativeFullTextSearch: false` and `titleOnly: true`, plus `pagesScanned`, per-page sources, `distinctTopicsScanned`, `matchingTopicsOmitted` and `nextBoardOffset`. That offset continues unread board pages. Matches omitted by `maxResults` belong to already scanned pages; increase the bound or narrow the query and repeat that starting window to inspect them. Native age/author/sort filters are not applied by this tool.

A zero-match result means no matching **titles within the scanned bounds**. It says nothing about message bodies, other boards or unvisited pages and must never be presented as an exhaustive full-text search or proof that a subject is absent from Underc0de.

## Output and evidence

Results retain source URL, fetched time and cache state. Message reads keep exact identifiers, author attribution, original displayed dates, edit text, code/quote boundaries and coverage metadata where the source markup supplies them. Unknown dates, timezones and reply parents remain unknown. Thread order is flat chronological; no reply tree is invented.

`fresh=true` bypasses this client's content cache and requests revalidation. The upstream forum or feed may maintain its own cache, so fetched time does not promise immediate visibility of a newly published post. Normal stdio disconnect releases the MCP session lock and detaches an attached browser. Replacing a closed forum tab reuses the existing browser connection.

Content budgets are explicit. `read_post` can continue at `body.coverage.nextContentOffset`; `extract_references` has a separate reference continuation. Page coverage and complete message-content coverage are different. A recent bump, translation or generated summary does not make an old original claim current. Actual Underc0de AI markers were observed on 2026-12-06: a direct message `.inner > .u0ia-tag` label and a board-title `.u0ia-chip[title="Generado por IA"]`. The parser reports `labeled_ai` for the corresponding explicit source marker; no marker means `unknown`, never a claim of human authorship. Keep any summary/derivative separate and never count it as independent corroboration.

Titles, usernames, quotes, links and code are untrusted external data. The server does not execute snippets, download attachments, visit extracted external links or test targets mentioned in posts. Primary-reference URLs in research plans are editorial recommendations and are not fetched by the planner.

## Configuration and limits

Variables are read from the process environment. `.env` files are **not automatically loaded**; [.env.example](.env.example) is documentation. No API key, OAuth token or forum password belongs in the public configuration.

| Setting | Default |
| --- | --- |
| `UNDERC0DE_TRANSPORT` | `auto` |
| `UNDERC0DE_CDP_ENDPOINT` | Unset; explicit existing loopback browser endpoint, e.g. `http://127.0.0.1:9222` |
| `UNDERC0DE_ATTACH_PROFILE_DIR` | Unset; alternative existing directory with `DevToolsActivePort` |
| `UNDERC0DE_BROWSER_FETCH` | `true`; supported same-origin session fetch |
| `UNDERC0DE_BROWSER_ENGINE` | `chromium`; optional `camoufox` |
| `UNDERC0DE_CAMOUFOX_RUNTIME_DIR` | `~/.underc0de-mcp/camoufox-runtime`; install explicitly |
| `UNDERC0DE_CAMOUFOX_EXECUTABLE` | Required absolute browser path for Camoufox |
| `UNDERC0DE_DATA_DIR` | `~/.underc0de-mcp` |
| `UNDERC0DE_CHROME_PATH` | Discover an installed Chrome/Edge executable |
| `UNDERC0DE_HEADLESS` | `true` |
| `UNDERC0DE_KEEP_BROWSER_ALIVE` | `true` for Chromium; `false` required for Camoufox |
| `UNDERC0DE_REQUEST_INTERVAL_MS` | `1500` |
| `UNDERC0DE_TIMEOUT_MS` | `20000` per HTTP attempt/browser navigation |
| `UNDERC0DE_BROWSER_START_TIMEOUT_MS` | `20000` |
| `UNDERC0DE_CHALLENGE_WAIT_MS` | `5000`; observe only, no automatic solving |
| `UNDERC0DE_CACHE_TTL_MS` | `30000` |
| `UNDERC0DE_MAX_CACHE_ENTRIES` | `100` |
| `UNDERC0DE_MAX_RETRIES` | `1` |
| `UNDERC0DE_MAX_RESPONSE_BYTES` | `4194304` — 4 MiB |
| `UNDERC0DE_USER_AGENT` | Descriptive project user agent for HTTP reads |

Each transport backend owns a memory-only cache with a 32 MiB serialized UTF-8 budget (at most 64 MiB across HTTP and browser backends); JavaScript heap overhead is additional. The adapter does not add a third content cache. At most 32 distinct reads may be pending. Cache entries are not a persistent forum database. Browser session/profile persistence is separate from content caching. The browser byte limit applies to the returned rendered document or XML body, not all traffic or memory used internally by the browser. Optional Camoufox checks its prepared model before launch and excludes default addons; run its fetch command outside MCP first.

Successful JSON payloads are capped at 250,000 JavaScript string characters. Complete MCP wire size is larger because text and structured forms are both returned. Per-message and aggregate budgets can shorten a result before the overall cap; inspect omission/truncation metadata.

These are client limits, not an operator-granted quota. No guaranteed Underc0de request allowance, exhaustive search count or permanent page size has been established. Respect rate-limit/cooldown responses. A valid current session does not guarantee future access.

## Commands and validation

```sh
npm run check
npm test
npm run build
node dist/cli.js doctor
node dist/cli.js check
npm run test:live
```

`doctor` checks local configuration without asserting network access. `check` requests real site content. `test:live` requires reachable, readable forum content/session state; it must not silently substitute fixtures or a search-engine copy. Offline tests use synthetic fixtures and verify contracts independently of the live site.

For recorded results and unresolved limitations, read [docs/validation.md](docs/validation.md). Live checks should run deliberately, not as a scheduled crawler. A successful offline test or CI run is not proof that Cloudflare will accept a new environment.

## Development

The project adapts transport, research and MCP foundations from the author's `elhacker-mcp` project; upstream helper notices are retained in [LICENSE](LICENSE). Site-specific routes, parser behavior and access evidence must be tested separately. Sibling MCP repositories are not modified or configured by this server.

Contributions should use focused Conventional Commits with real creation timestamps. Do not commit browser profiles, credentials, private target details, scraped full posts or local configuration. See [CONTRIBUTING.md](CONTRIBUTING.md) and [SECURITY.md](SECURITY.md).

MIT licensed. Forum content remains subject to its original authors' rights and the site's terms.