Cover image
Try Now
2025-04-08

MCP Server für LLM zum Testen der API

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

mcp-api-tester Tools & Interfaces

This document summarizes potential tools or interfaces that enable an LLM (Large Language Model) to perform automated API testing. By leveraging these tools, the LLM can read API documentation, select and test specific endpoints using net/http, and help developers quickly identify potential issues.

Core Tools (Minimal Viable Tools)

The following three tools are the most basic and essential interfaces, allowing the LLM to conduct minimum viable automated testing:

  1. listAllAPIFromDocument

    • Purpose: Lists all available APIs (name, URL, HTTP method, etc.) from the documentation.
    • Example: A sample return value might look like:
      [
        { "name": "getUser", "method": "GET", "url": "/users/{id}" },
        { "name": "createUser", "method": "POST", "url": "/users" }
        ...
      ]
      
    • When the LLM Uses It: To browse available APIs and choose which to test.
  2. getSingleAPIDetail

    • Purpose: Retrieves detailed documentation of a specific API by name or path, such as:
      • Request parameters (query, path, body, etc.)
      • Response structure (schema)
      • Possible status codes and error definitions
    • Example: A sample return value might look like:
      {
        "name": "getUser",
        "method": "GET",
        "url": "/users/{id}",
        "parameters": [
          { "in": "path", "name": "id", "type": "string", "required": true }
        ],
        "responses": {
          "200": {
            "description": "Returns user data on success",
            "schema": { ... }
          },
          "404": {
            "description": "User not found"
          }
        }
      }
      
    • When the LLM Uses It: To generate test parameters and expected responses for a specific endpoint.
  3. callNetHTTP

    • Purpose: Allows the LLM to send real HTTP requests and receive results (status code, headers, body).
    • Example:
      {
        "request": {
          "method": "POST",
          "url": "/users",
          "headers": { "Content-Type": "application/json" },
          "body": { "name": "NewUser", "age": 30 }
        },
        "response": {
          "status": 201,
          "headers": { ... },
          "body": { "id": "123", "name": "NewUser", "age": 30 }
        }
      }
      
    • When the LLM Uses It: To execute test calls and compare actual results against expected outcomes.

Advanced Suggested Tools (Enhanced Tools)

These tools are not mandatory, but they can significantly improve automated testing, reporting, environment setup, and more.

1. Response Validation / Parsing Tools

  1. Schema Validation

    • validateResponseWithSchema(responseBody, schemaInfo) -> (isValid, errorList)
    • Compares the returned JSON body against the documented schema to check for field consistency, data types, and any required fields.
  2. JSON Parsing

    • parseJSON(responseBody) -> (parsedObject)
    • Enables the LLM to conveniently read and inspect specific fields in the response (e.g., confirm that certain fields are not empty).

2. Context / Logging Tools for Test Execution

  1. Test Result Logging / Storage

    • storeTestResult(testCase, response, passOrFail, errorMessage)
    • Lets the LLM record execution details, errors, and outcomes for each test case, making it easier to compile reports.
  2. Historical Test Results

    • getTestHistory(apiName or endpoint) -> (historyData)
    • Allows the LLM (or other systems) to query past test results for the same endpoint and understand regressions or changes over time.

3. Environment Setup / Management Tools

  1. Authentication / Credential Setup

    • getAuthToken(username, password) -> token
    • Some APIs require a token or cookie for authentication. The LLM may need to call this tool first to obtain proper credentials.
  2. Reset / Initialize Test Data

    • resetTestData() or seedTestData()
    • Ensures the database or system state is in a known default condition before testing begins.

4. Fuzz / Edge Case Testing Tools

  • generateFuzzyInput(fieldType, constraints)
  • Returns extreme or unusual input (e.g., negative values, extremely large values, random characters, special symbols) for stress-testing and security checks.

Recommended Development Flow

  1. Integrate the Minimal Viable Tools

    1. Implement listAllAPIFromDocument, getSingleAPIDetail, and callNetHTTP in your system so the LLM can:
      • Obtain a list of available endpoints
      • Fetch detailed specs for a given API
      • Make real HTTP requests
  2. Connect the LLM

    • Enable the LLM to use the above three tools. It can list potential endpoints, retrieve details for each, generate test scenarios, and finally run them via callNetHTTP.
  3. Add Validation Tools (Response / Schema)

    • Provide utilities that let the LLM verify whether returned data matches the documented schema and expectations.
  4. Expand on Test Logging & Environment Management

    • Offer interfaces for storing test results, querying historical tests, resetting the environment, and retrieving auth tokens.
    • The LLM can call these tools to maintain a consistent state and documentation of test processes.
  5. Fuzz / Edge Case Testing

    • Integrate a tool to generate malicious or extreme values, or let the LLM generate them automatically to conduct in-depth stress or security testing.

Important Notes

  • Security & Permissions

    • When the LLM makes API calls, ensure these tests run in a safe environment (development or sandbox) and do not compromise sensitive data.
  • Accuracy of LLM-Generated Content

    • The LLM may produce invalid or incorrect parameters. Additional validation or error handling may be needed in your interfaces.
  • Cannot Completely Replace Traditional Testing

    • While the LLM can quickly produce boundary and abnormal test cases, traditional unit tests remain essential for thorough coverage.

Test

ReadOpenAPIDocument

curl -X POST --data '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
  "name": "ReadOpenAPIDocument",
  "arguments": {
    "openAPIPath": "/absolute/path/to/your/openAPI/file"
  }
}
}' http://localhost:8000/message?sessionId=9fa4fc8c-1799-4955-a0bb-4881258f13f9

ListAllAPIFromDocument

curl -X POST --data '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
  "name": "ListAllAPIFromDocument"
}
}' http://localhost:8000/message?sessionId=9fa4fc8c-1799-4955-a0bb-4881258f13f9

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.

  • jae-jae
  • MCP -Server für den Fetch -Webseiteninhalt mit dem Headless -Browser von Dramatikern.

  • HiveNexus
  • Ein KI-Chat-Bot für kleine und mittelgroße Teams, die Modelle wie Deepseek, Open AI, Claude und Gemini unterstützt. 专为中小团队设计的 ai 聊天应用 , 支持 Deepseek 、 Open ai 、 claude 、 Gemini 等模型。

  • ravitemer
  • Ein leistungsstarkes Neovim -Plugin für die Verwaltung von MCP -Servern (Modellkontextprotokoll)

  • patruff
  • Brücke zwischen Ollama und MCP -Servern und ermöglicht es lokalen LLMs, Modellkontextprotokoll -Tools zu verwenden

    Reviews

    1 (1)
    Avatar
    user_vAstHc42
    2025-04-17

    I've been using mcp-api-tester and I'm thoroughly impressed with its performance. Created by TinyMurky and easily accessible via [GitHub](https://github.com/TinyMurky/mcp-api-tester), this tool is essential for efficient API testing. The seamless integration and user-friendly interface make it a top choice for developers looking to streamline their testing processes. Highly recommended!