OJ API
Reference

MCP Reference

Use the mounted MCP transport when you want tool-based access to the same public problem, daily, similarity, and status capabilities.

Version 0.3.3 · The mounted MCP transport is currently reachable without bearer auth.

Section

Transport

Document the two HTTP surfaces exposed by the mounted Streamable HTTP MCP service.

POST /mcp

Streamable HTTP entrypoint

#

Primary Streamable HTTP endpoint for initialize and tool-call requests.

Auth
Bearer auth follows the existing MCP middleware setting.
Expand transport details

Example

curl -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' http://127.0.0.1:7856/mcp
GET /mcp

SSE session stream

#

SSE/session-resume transport surface exposed by the mounted MCP service.

Auth
Bearer auth follows the existing MCP middleware setting.
Expand transport details

Example

curl -N -H 'Authorization: Bearer <token>' http://127.0.0.1:7856/mcp
Section

Tools

Each MCP tool maps back to an existing public REST capability while returning plain-language output for tool clients.

TOOL resolve_problem

Resolve a problem from flexible input

#
Inputs
query
REST capability
Maps to GET /api/v1/resolve/{*query}.
Expand tool details

Output style

Text summary of the resolved problem detail.

Usage note

Use when the source/ID format is uncertain or when the input is a URL.

TOOL get_problem

Fetch one normalized problem

#
Inputs
source, id
REST capability
Maps to GET /api/v1/problems/{source}/{id}.
Expand tool details

Output style

Text summary of the requested problem detail.

Usage note

Use when the caller already knows the normalized source and problem ID.

TOOL get_daily_challenge

Read the current daily challenge

#
Inputs
domain?, date?
REST capability
Maps to GET /api/v1/daily.
Expand tool details

Output style

Text summary of the daily challenge or the active fetch state.

Usage note

Use when the caller wants the current daily challenge without composing REST query strings.

TOOL find_similar_problems

Search similar problems

#
Inputs
query or source+id, plus limit/threshold/source_filter?
REST capability
Maps to GET /api/v1/similar and GET /api/v1/similar/{source}/{id}.
Expand tool details

Output style

Text ranking of similar problems with similarity scores.

Usage note

Use text query mode for semantic search or source+id mode for seed-problem lookup.

TOOL get_platform_status

Check indexed platform status

#
Inputs
none
REST capability
Maps to GET /status.
Expand tool details

Output style

Text summary of service version and platform stats.

Usage note

Use for a compact operational overview of available indexed platforms.

Section

Examples

Start with one connection snippet and one JSON-RPC request to verify auth, transport, and tool naming.

CONFIG mcpServers.oj-api

Connection example

#

Point your MCP client at the mounted HTTP endpoint and send the same bearer token you use for protected public routes.

{
  "mcpServers": {
    "oj-api": {
      "transport": {
        "type": "streamable-http",
        "url": "http://127.0.0.1:7856/mcp",
        "headers": {
          "Authorization": "Bearer <token>"
        }
      }
    }
  }
}
JSON-RPC tools/call

Request example

#

This request asks the MCP server to run the exact tool name get_problem with the same source and ID you would send to the REST detail endpoint.

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_problem",
    "arguments": {
      "source": "leetcode",
      "id": "1"
    }
  }
}