Skip to content

opencontextprotocol/ocp-registry

Repository files navigation

OCP Registry

Community-driven API registry for the Open Context Protocol. Browse APIs at opencontextprotocol.io/registry or access programmatically via the API at opencontextprotocol.io/api/v1.

Architecture

Dual Deployment Model:

  • Frontend: Static content generated and integrated into ocp-spec Hugo site
  • Backend: FastAPI service providing registry data and search
  • Data Source: YAML files in data/ as single source of truth
  • Deployment: Automated via GitHub Actions → GHCR → VPS

Repository Structure

ocp-registry/
├── data/                    # Source of truth
│   ├── apis/
│   │   ├── github/
│   │   │   ├── meta.yaml
│   │   │   └── tools.json   (generated)
│   │   └── stripe/
│   │       ├── meta.yaml
│   │       └── tools.json   (generated)
│   └── categories.yaml
├── scripts/                 # Build tools
│   ├── generate-tools.py    # Fetch OpenAPI specs → tools.json
│   └── build-database.py    # YAML + tools.json → SQLite
├── src/
│   └── ocp_registry/        # FastAPI service
│       ├── main.py
│       ├── models.py
│       ├── database.py
│       └── service.py
└── tests/                   # API tests

Quick Start

For Library Users

from ocp_agent import OCPAgent

# Libraries use https://opencontextprotocol.io/api/v1
agent = OCPAgent(registry_url='https://opencontextprotocol.io/api/v1')
api = await agent.register_api('github')
import { OCPAgent } from '@opencontextprotocol/agent';

const agent = new OCPAgent(
  'my-agent',
  'user',
  'workspace',
  'description',
  'https://opencontextprotocol.io/api/v1'
);

For Local Development

# Clone and setup
git clone https://github.com/opencontextprotocol/ocp-registry.git
cd ocp-registry
poetry install

# Generate tools from OpenAPI specs
poetry run python scripts/generate-tools.py

# Build database
poetry run python scripts/build-database.py

# Run API service
poetry run uvicorn src.ocp_registry.main:app --reload

# API available at http://localhost:8000

API Endpoints

All endpoints are prefixed with /api/v1:

GET  /api/v1/registry              # List all APIs
GET  /api/v1/registry/{name}       # Get specific API with tools
GET  /api/v1/search?q={query}      # Search APIs by name/description
GET  /api/v1/stats                 # Registry statistics
POST /api/v1/registry              # Register new API (validation)

Adding Your API

  1. Fork this repository

  2. Create API metadata:

    mkdir data/apis/my-api
    cat > data/apis/my-api/meta.yaml << EOF
    name: my-api
    display_name: My Amazing API
    description: What your API does
    openapi_url: https://api.example.com/openapi.json
    base_url: https://api.example.com
    category: development
    tags: [example, demo]
    status: active
    EOF
  3. Test locally:

    poetry run python scripts/generate-tools.py my-api
    poetry run python scripts/build-database.py
  4. Submit PR - CI will validate, generate tools, and deploy automatically

Build Scripts

generate-tools.py

Fetches OpenAPI specs and generates tools.json for each API:

poetry run python scripts/generate-tools.py              # Process all APIs
poetry run python scripts/generate-tools.py github       # Process specific API

Note: tools.json files are committed to the repository. Run this script when adding new APIs or updating existing ones.

build-database.py

Builds SQLite database from YAML metadata and generated tools:

poetry run python scripts/build-database.py              # Creates registry.db
poetry run python scripts/build-database.py /path/db     # Custom database path

Deployment

Automated (Production)

Push to main branch triggers:

  1. GitHub Actions builds Docker image
  2. Image pushed to ghcr.io/opencontextprotocol/ocp-registry:latest
  3. Triggers deployment on VPS via ocp-server
  4. Services restart with latest image

Docker Build (Local Testing)

# Build image
docker build -t ocp-registry .

# Run container
docker run -p 8000:8000 ocp-registry

# Test API
curl http://localhost:8000/api/v1/registry

Manual Development

# Build database from sources
poetry run python scripts/build-database.py

# Run API service
poetry run uvicorn src.ocp_registry.main:app --host 0.0.0.0 --port 8000

Testing

# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov=src/ocp_registry

# Test specific API endpoint
curl "https://opencontextprotocol.io/api/v1/search?q=github"
curl "https://opencontextprotocol.io/api/v1/registry/github"

Development

# Format code
poetry run black src/ scripts/
poetry run isort src/ scripts/

# Type checking
poetry run mypy src/

# Linting
poetry run ruff check src/ scripts/

About

Searchable database of pre-indexed APIs

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •