Implementation:0xSteph Pentest ai MCP REST Adapter
| Knowledge Sources | |
|---|---|
| Domains | REST, MCP, Plugin_Integration |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for exposing ptai's MCP tools as plain REST routes for plugin clients like Caido, Burp, and ZAP, provided by the pentest-ai MCP server.
Description
The mcp_server.rest module registers thin Starlette REST routes via FastMCP's @mcp.custom_route() decorator that delegate to the existing @mcp.tool() functions. No duplicated business logic — each route unpacks the request, calls the tool function, and serializes the dict response. Routes: GET /v1/health, GET /v1/findings, POST /v1/http_request, GET /v1/evidence. The shared LocalAuthMiddleware enforces the same security posture as MCP consumers.
Usage
This module is import-side-effect only — decorators register against the shared mcp instance at module load. Imported from mcp_server.server.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: mcp_server/rest.py
- Lines: 1-151
Signature
# Routes registered via @mcp.custom_route():
# GET /v1/health -> health()
# GET /v1/findings -> get_findings(...)
# POST /v1/http_request -> http_request(...)
# GET /v1/evidence -> get_evidence(...)
Import
# Side-effect import — routes register on the shared mcp instance
import mcp_server.rest # noqa: F401
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | str (header) | Yes | Bearer token (LocalAuthMiddleware) |
| Host | str (header) | Yes | Must be in allowlist |
| JSON body | dict | Yes (POST) | Request payload for http_request |
Outputs
| Name | Type | Description |
|---|---|---|
| JSON response | JSONResponse | Serialized tool function result |
Usage Examples
Call REST Routes
# Health check
curl -H "Authorization: Bearer $(cat ~/.pentest-ai/mcp-token)" \
http://127.0.0.1:8080/v1/health
# Get findings
curl -H "Authorization: Bearer $TOKEN" \
http://127.0.0.1:8080/v1/findings?engagement_id=abc
# Make an HTTP request through ptai
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com", "method": "GET"}' \
http://127.0.0.1:8080/v1/http_request