Skip to main content
Glama
SHREELASYABEZAWADA

api-testing-agent

MCP API Testing Agent

AI 기반 API 테스트 에이전트로, **Model Context Protocol (MCP)**을 사용하여 API 테스트 이스 생성, 실해, 실패 분을 자동화합니다.

하는 일

  1. 발견: MCP 도구를 통해 OpenAPI/Swagger 스펙에서 엔드포인트를 찾습니다.

  2. 생성: LLM(LangChain + OpenAI)을 사용하여 각 엔드포인트에 대한 정상/비정상 테스트 시나리오를 생성합니다 — 유효한 입력, 필수 필수 누락, 잘못된 타입, 경계값, 인증 실패 등.

  3. 실행: MCP 도구를 통해 요청을 보내고 응답을 검증하며 HTTP 상태 코드를 분석하는 방식으로, 각 테스트 리를 실제로 사용 중인 API에 실행합니다.

  4. 실패 분서: 예상 응답과 실응답을 비교(diff)하고, LLM(텍스트 실패 원인을 설명하도록 요청)에게 테스트가 왜 실패했는지와 심가도를 설명합니다.

  5. 보고: 정규화된 Markda/JSON 테스트 리에 대한 결과로 작성합니다.

FastAPI 서비스가 전체 파이프라인을 래핑하며, HTTP(POST /agent/run)로 실행할 수 있고 — 예: CI, 스케줄러, UI — 또한 MCP 서버는 단독으로 실행하여 어떤 MCP 호환 클라이언트(Claude Desktop, Claude Code 등)에 연결할 수도 있습니다.

Related MCP server: MCP-QA

아키텐처

GXP

프로젝트 구조

mcp-api-testing-agent/
├── mcp_server/
│   ├── server.py               # MCP server (FastMCP) exposing the 4 tools
│   └── tools/
│       ├── discover.py         # discover_endpoints — parses OpenAPI spec
│       ├── request_tool.py     # send_request — issues HTTP calls
│       ├── validate.py         # validate_response — schema/status checks
│       └── status_analyzer.py  # analyze_status_code — status code semantics
├── agent/
│   ├── mcp_client.py           # stdio MCP client used by the agent
│   ├── test_generator.py       # LLM-based positive/negative test generation
│   ├── test_executor.py        # runs generated test cases via MCP tools
│   ├── failure_analyzer.py     # LLM explains expected-vs-actual mismatches
│   └── report_generator.py     # Markdown + JSON report writer
├── api/
│   └── main.py                  # FastAPI app: POST /agent/run, GET /agent/reports/{id}
├── schemas/
│   └── models.py                # Pydantic models shared across the app
├── sample_target_api/
│   └── demo_api.py              # tiny FastAPI service to test the agent against
├── scripts/
│   └── run_agent.py             # CLI entrypoint (no FastAPI needed)
├── reports/                     # generated test reports land here
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── .env.example

설정

python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # add your OPENAI_API_KEY

데모 타깃 API 실행 (테스트에 사용할 작은 샘플 API)

GXP

이 명령은 샘플 "Task Manager" API를 표시하며, /tasks CRUD 엔드포인트와 생성된 OpenAPI 스펙를 http://localhost:9000/openapi.json에서 제공합니다.

CLI로 에이전트 실행

python scripts/run_agent.py --spec http://localhost:9000/openapi.json --base-url http://localhost:9000

이 명령은 테스트 이스를 생상, 실패하고, 실패한 결과를 분서하여 reports/report_<timestamp>.md 및 .json 리포트 파일를 작성합니다.

HTTP 서비스로 에이전트 실행

uvicorn api.main:app --port 8000
curl -X POST http://localhost:8000/agent/run \
  -H "Content-Type: application/json" \
  -d '{"spec_url": "http://localhost:9000/openapi.json", "base_url": "http://localhost:9000"}'

MCP 서버 단독 실행

빌트인 에이전트 대인 이 도구를 MCP 호환 클라이언트(Claude Desktop, Claude Code 등)에 연결하려면:

python -m mcp_server.server

그런 다음을 이를 MCP 클라이언트 구에 추가합니다. 예를 들어 Claude Desktop(claude_desktop_config.json)의 경우:

┌─────────────────────┐      OpenAPI spec / target base URL
│   FastAPI Service    │◄──────────────────────────────────
│   (api/main.py)      │
└──────────┬───────────┘
           │ triggers
┌──────────▼───────────┐
│   Testing Agent        │
│   (agent/*.py)         │
│                         │
│  1. TestGenerator       │──uses──► OpenAI (LangChain)
│     (positive/negative  │
│      scenarios)         │
│                         │
│  2. TestExecutor        │──calls──► MCP Client ──stdio──► MCP Server
│     (runs each case)    │                                  │
│                         │                          ┌───────┴────────┐
│  3. FailureAnalyzer     │                          │  MCP Tools:     │
│     (LLM explains diff) │                          │  - discover_    │
│                         │                          │    endpoints    │
│  4. ReportGenerator     │                          │  - send_request │
│     (md/json report)    │                          │  - validate_    │
└─────────────────────────┘                          │    response     │
                                                       │  - analyze_    │
                                                       │    status_code │
                                                       └────────┬───────┘
                                                                │ HTTP
                                                       ┌────────▼───────┐
                                                       │  Target API     │
                                                       │  (any REST API, │
                                                       │  e.g. sample_   │
                                                       │  target_api/)   │
                                                       └─────────────────┘

Docker로 전체 실행

docker compose up --build

이는 데모 API와 MCP 기반 테스트 에이전트 FastAPI 서비스를 시작하고, ./reports를 마운트하여 생성된 리포트를 호스트에서 확인할 수 있게 합니다.

샘플 리포트 출력

# API Test Report — 2026-02-03T10:15:00

Target: http://localhost:9000
Total: 18   Passed: 15   Failed: 3   Pass rate: 83%

## Failures

### POST /tasks — missing required field "title" (negative test)
Expected: 422 Unprocessable Entity
Actual:   500 Internal Server Error
Analysis: The endpoint does not validate the request body before hitting the
database layer, so a missing "title" causes an unhandled exception instead
of a client-error response. Severity: High — indicates missing input
validation.

실제 프로젝트에 적용할 때 참고 사항

  • sample_target_api/를 실제 서비스로 교체하거나, --spec / spec_url을 라이브 OpenAPI/Swagger JSON 엔드포인트로 지정하세요.

  • test_generator.py의 프롬프트를 확장해 도메인 규칙(예: 필수 인증 헤더, rate limits, tenant IDs)을 반영할 수 있습니다.

  • CI에서는 scripts/run_agent.py를 파이프라인 단계로 실행하고, report["summary"]["failed"] > 0이면 빌드를 실패시키세요.

Need check "MCP" in title? In final I wrote "MCP API Testing Agent" as heading. Good.

But I see in Korean text "요청" in item 3, but "요청을 보내고 응답" etc. Fine.

However, one issue: "LLM(테스트 실패 원인을 설명하도록 요청)에게" is awkward. Let's improve in final.

Need maybe "R를 diff, LLM(MCP)에게" no. We can revise final proper.

Let's produce final refined full with correct "테스트가 왜 실패했는지의 심각도를 설명합니다." Good.

Also "단독으로" no "단독로".

Let's ensure "FastAPI 서비스가 entire pipeline을 둥글게". well.

Need "Desktop" etc.

Potential issue with "as an HTTP service" heading: "HTTP 서비스로 에이전트 실행" good.

Need "sample report output" -> "샘플 리포트 출력" good.

Need "Notes on adjusting..." good.

I'll now provide# MCP API Testing Agent

AI 기반 API 테스트 에이전트로, **Model Context Protocol (MCP)**을 사용하여 API 테스트 케이스 생성, 실행, 실패 분석을 자동화합니다.

하는 일

  1. 발견: MCP 도구를 통해 OpenAPI/Swagger 스펙에서 엔드포인트를 찾습니다.

  2. 생성: LLM(LangChain + OpenAI)을 사용해 각 엔드포인트에 대한 정상/비정상 테스트 시나리오를 생성합니다 — 유효한 입력, 필수 필드 누락, 잘못된 타입, 경계값, 인증 실패 등.

  3. 실행: 요청을 보내고 응답을 검증하며 HTTP 상태 코드를 분석하는 MCP 도구를 통해, 각 테스트 케이스를 라이브 API에 대해 실행합니다.

  4. 실패 분석: 예상 응답과 실제 응답을 비교(diff)하고, LLM에게 테스트가 왜 실패했는지와 심각도를 설명하도록 요청합니다.

  5. 보고: 구조화된 Markdown/JSON 테스트 리포트로 결과를 작성합니다.

FastAPI 서비스는 전체 파이프라인을 감싸 감 чтобы HTTP(POST /agent/run)로 트리거할 수 있습니다 — 예를 들어 CI, 세줄러, UI 등입니다 — 그리고 MCP 서버는 독립 실행해서 MCP-호환 클라이언트(Claude Desktop, Claude Code 등)에 연결될 수도 있습니다.

아키텍처

GXP

프로젝트 구조

mcp-api-testing-agent/
├── mcp_server/
│   ├── server.py               # MCP server (FastMCP) exposing the 4 tools
│   └── tools/
│       ├── discover.py         # discover_endpoints — parses OpenAPI spec
│       ├── request_tool.py     # send_request — issues HTTP calls
│       ├── validate.py         # validate_response — schema/status checks
│       └── status_analyzer.py  # analyze_status_code — status code semantics
├── agent/
│   ├── mcp_client.py           # stdio MCP client used by the agent
│   ├── test_generator.py       # LLM-based positive/negative test generation
│   ├── test_executor.py        # runs generated test cases via MCP tools
│   ├── failure_analyzer.py     # LLM explains expected-vs-actual mismatches
│   └── report_generator.py     # Markdown + JSON report writer
├── api/
│   └── main.py                  # FastAPI app: POST /agent/run, GET /agent/reports/{id}
├── schemas/
│   └── models.py                # Pydantic models shared across the app
├── sample_target_api/
│   └── demo_api.py              # tiny FastAPI service to test the agent against
├── scripts/
│   └── run_agent.py             # CLI entrypoint (no FastAPI needed)
├── reports/                     # generated test reports land here
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── .env.example

설정

python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # add your OPENAI_API_KEY

데모 실행 대상 API 실행 (테스트에 사용할 작은 샘플 API)

uvicorn sample_target_api.demo_api:app --port 9000

이 명령은 샘플 "Task Manager" API를 노출하며, /tasks CRUD 엔드포인트와 생성된 OpenAPI 스펙를 http://localhost:9000/openapi.json에서 제공합니다.

CLI에서 에이전트 실행

python scripts/run_agent.py --spec http://localhost:9000/openapi.json --base-url http://localhost:9000

이 명령은 텍스트 이스를 생성하고, 실행하고, 실패를 분해, reports/report_<timestamp>.md와 .json로 리포트를 작합니다.

HTTP 서비스로 에이전트 실행

uvicorn api.main:app --port 8000
curl -X POST http://localhost:8000/agent/run \
  -H "Content-Type: application/json" \
  -d '{"spec_url": "http://localhost:9000/openapi.json", "base_url": "http://localhost:9000"}'

MCP 서버 단독 실행

빌트인 에이전트 대신 이 도구를 MCP-호환 엔드포인트(Claude Desktop, Claude Code 등)에 연결하려면:

python -m mcp_server.server

그런다음 이를 MCP 클라이언트 설정에 추가합니다. 예를 들어 Claude Desktop(claude_desktop_config.json)의 경우:

{
  "mcpServers": {
    "api-testing-agent": {
      "command": "python",
      "args": ["-m", "mcp_server.server"],
      "cwd": "/absolute/path/to/mcp-api-testing-agent"
    }
  }
}

Docker로 전체 실행

docker compose up --build

이 명령은 데모 대상 API와 MCP 기반 테스트 에이전트 FastAPI 서비스를 시작하고, ./reports를 마운트하여 생성된 리포트를 호스트에서 확인할 수 이도록 합니다.

리포트 예시 출력

# API Test Report — 2026-02-03T10:15:00

Target: http://localhost:9000
Total: 18   Passed: 15   Failed: 3   Pass rate: 83%

## Failures

### POST /tasks — missing required field "title" (negative test)
Expected: 422 Unprocessable Entity
Actual:   500 Internal Server Error
Analysis: The endpoint does not validate the request body before hitting the
database layer, so a missing "title" causes an unhandled exception instead
of a client-error response. Severity: High — indicates missing input
validation.

실제 프로젝트에 적응 시 참고 사항

  • sample_target_api/를 실제 서비스로 교체하고, --spec / spec_url를 실제 운영 중인 OpenAPI/Swagger JSON API 엔드포인트로 지정하세요.

  • test_generator.py의 프롬프트를 확장하여 도메인 규칙(예: 필수 인증 헤더, 요율 제한, tenant ID)을 추가할 수 있습니다.

  • CI에서는 scripts/run_agent.py를 파이프라인 단계로 실행하고, report["summary"]["failed"] > 0이면 빌드를 실패되도록 하세요.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server for the comprehensive analysis of Swagger 2.0 and OpenAPI 3.x contracts. It allows users to extract detailed information about endpoints, request/response schemas, parameters, and security configurations from API documentation.
    -
  • A
    license
    A
    quality
    F
    maintenance
    MCP server for API test case generation from Swagger/OpenAPI specs. Parses Swagger 2.0 and OpenAPI 3.x, generates test cases across 8 categories (positive, negative, boundary, auth, security, idempotency, pagination, business logic), and exports to Postman, TestRail, Allure, k6, pytest, Gherkin, and CSV. Supports internal corporate APIs with auth headers. Auto-saves export files to your working di
    10
    10 npm
    2
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Parses Swagger 2.0 and OpenAPI 3.x specifications, exposing API endpoints, schemas, and authentication through MCP tools with local caching to reduce token usage.
    11
    3 npm
    1
    MIT