# Endpoint Context Protocol (ECP)

A few lines of code to make any existing website agent-friendly.

Endpoint Context Protocol (ECP) is built on HTTP Content Negotiation headers that have been powering the web since 1999. The headers are already there. ECP puts them to use. The result? Your existing site serves humans and agents from the *same* URL, no new internet infrastructure required.

## What This Is

HTTP content negotiation has been in the spec since RFC 2616 in 1999. Browsers use it constantly. They send `Sec-Fetch-Dest: document` and `Accept: text/html` on every navigation. Every other HTTP client — agents, LLMs, curl, automated scripts, etc — do not.

That distinction has always been there. ECP is just a method for acting on it; inspect those two headers, return clean semantic content to agentic callers, return your existing HTML to everyone else. The URL never changes. No new routing. No subdomains. No special agent training required.

This is not a new protocol or app layered on top of the web. **It *is* the web, finally used as intended.**

## What This Unlocks

Your canonical domain stops being a static brochure and becomes a live intelligence surface. Agents can arrive through the same front door and get exactly what you choose to expose, with first-party authority and current operational context.

- **URL-first discovery:** no prior relationship required to discover capabilities.
- **Live operational context:** inventory, specials, availability, and status can be updated in real time.
- **Actionable API & MCP discovery:** agents can find endpoints plus auth and token instructions at request time.
- **One trusted authority:** humans and agents both resolve to the same canonical domain.

**One canonical domain. One front door. Two audience-optimized representations.**

## The Code

No external packages needed. 2 simple steps:

**Step 1 — Create `ecp.json` in your site root.**

This allows select hosting providers to handle `routes["/"]` to your root-bound markdown URL: `https://your-domain.com/AgentWelcome.md`.

```json
{
  "$schema": "https://endpointcontextprotocol.io/schema/v1.json",
  "version": "1.0",
  "instructions": [
    "- Welcome to Endpoint Context Protocol (ECP).",
    "- This file tells AI agents where to find your site's Markdown context.",
    "- Routes explicitly map a URL path to a Markdown file or external URL.",
    "- Because ECP is strictly opt-in, unlisted routes are automatically safe.",
    "- Mapping the root '/' is usually all you need."
  ],
  "routes": {
    "/": "https://your-domain.com/AgentWelcome.md"
  },
  "use-agents-subdomain": false
}
```

*`use-agents-subdomain` remains false for most cases not using specific third-party ECP Context Servers.*

**Step 2 — Wire agent/human request handling.**

Fetch the URL for your specific platform to get exact implementation code and instructions:

- Cloudflare Pages/Workers: https://endpointcontextprotocol.io/cloudflare
- Next.js (App or Pages Router): https://endpointcontextprotocol.io/nextjs
- Vercel (Routing Middleware): https://endpointcontextprotocol.io/vercel
- Netlify (Edge Functions): https://endpointcontextprotocol.io/netlify
- Firebase Hosting & Functions: https://endpointcontextprotocol.io/firebase
- cPanel / Apache Shared Hosting (.htaccess 302): https://endpointcontextprotocol.io/cpanel
- Express / Node.js: https://endpointcontextprotocol.io/express
- WordPress / PHP: https://endpointcontextprotocol.io/php
- Generic Static Site + proxy: https://endpointcontextprotocol.io/static

Upon deploy, requests from agents to `/` that match ECP negotiation are served from the AgentWelcome.md route declared in `ecp.json`. Human traffic continues to receive a normal web experience.

That AgentWelcome.md URL is yours to control. Three common choices:

- **An AgentWelcome.md file you host.** Write it once, update whenever you want, full control.
- **Any public URL.** A Gist, a Notion page, a Google Doc export — if it's fetchable, it works.
- **A hosted ECP Context Server.** Your same URL, dynamically maintained, extra features, no ongoing site changes.

## Install Anywhere

If you want LLM-ready, stack-specific instructions generated from your actual codebase, run:

```
npx endpointcontext
```

The CLI scans your project, detects your framework, prompts for your domain and AgentWelcome.md URL, then writes `ecp.json` and a platform-specific `ECP_Install_Guide.md` ready to hand to your coding agent.

- **Cloudflare / Vercel / Netlify / Node middleware:** add the request check in your middleware or edge handler.
- **WordPress / PHP:** plugin-first path; code snippet fallback only when needed.
- **Shared hosting:** usually same as WordPress/PHP unless static-only.
- **Static-only hosting:** use an external proxy path (Cloudflare or hosted ECP context services).

Optional discovery hint — add in your `<head>` for HTML-scraping agents:

```html
<link rel="alternate" type="text/markdown" href="https://your-domain.com/AgentWelcome.md" title="agent-context" />
```

Fallback breadcrumb for agents that scrape full HTML instead of negotiating directly.

## Hosted ECP Context Servers

A hosted ECP Context Server is a single URL you drop into the handler above. Instead of maintaining a static knowledge cache yourself, the server delivers a dynamic knowledge cache kept current, richly structured, and built to be read by agents.

No ongoing site changes needed. Update your context from any third-party dashboard you choose, or build your own. Agents calling your site get the new version automatically.

Hosted context servers also unlock the `agents.*` subdomain: an isolated container for advanced context delivery, API token generation, and agent-specific capabilities that live alongside your main site without touching it. See ecpservers.com.

## ECP.Directory

As agents increasingly discover sites without human-initiated search, the ECP index gives your site a verified presence in that layer. Submit once at ecp.directory. The index is opt-in, free, and queried directly by model providers and agent frameworks.

## See It Live

packages.report runs ECP in production. Any npm package URL returns semantic markdown to non-browser callers. Same URL, same authority — content negotiated at request time.

```bash
# browser gets the full HTML package report
open https://packages.report/npm/inquirer

# agent gets structured markdown, same URL
curl https://packages.report/npm/inquirer
```
