Socket
Book a DemoInstallSign in
Socket

swagger-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-api

A tool to fetch and parse Swagger API definitions from a given URL.

pipPyPI
Version
1.0.0
Maintainers
1

Swagger API MCP Server

A Model Context Protocol (MCP) server that extracts API definitions from Swagger/OpenAPI JSON endpoints. This tool provides structured access to API paths and schemas from various internal HP services.

Features

  • 🔍 API Discovery: Browse available APIs through a curated list of base URLs
  • 📝 Schema Extraction: Extract comprehensive API definitions including paths and schemas
  • 🚀 Fast Integration: Easy integration with MCP-compatible clients

Installation

pip install swagger-api-mcp

Usage

As an MCP Server

Start the server:

python -m swagger_api.swagger_api

Available Tools

1. base_url_list

Lists available Swagger API endpoints with descriptions.

Returns:

  • List of available APIs with their base URLs and descriptions
  • Includes DCC Notifications API, Device View API, and Supply Order API

2. get_swagger_api_defs_from_json

Extracts API definitions from a Swagger JSON endpoint.

Parameters:

  • swagger_json_url: URL to the swagger.json endpoint
  • base_url: Base URL for the API service

Returns:

  • API paths and their definitions
  • Schema definitions for data models
  • Base URL for the service

Example Usage

from swagger_api.swagger_api import mcp

# Get list of available APIs
apis = base_url_list()

# Extract API definitions
api_defs = await get_swagger_api_defs_from_json(
    swagger_json_url="https://example.com/api-docs/swagger.json",
    base_url="https://example.com"
)

Available APIs

The server provides access to the following internal HP APIs:

DCC Notifications API

  • Base URL: https://mscc-svc.api.dev-thor-ue1.hpip-internal.com/svc/dcc-notifications
  • Description: Provides access to DCC notifications
  • Swagger JSON: Available at /api-docs/swagger.json

Device View API

  • Base URL: https://dss-svc.api.dev-thor-ue1.hpip-internal.com/svc/device-view
  • Description: Provides access to device view functionalities and device data
  • Swagger JSON: Available at /api-docs/swagger.json

Supply Order API

  • Base URL: https://hpcorp-ob-test.default.api.hp.com/device-view-service-dev/svc/supply-order
  • Description: Provides access to supply order functionalities
  • Swagger JSON: Available at /api-docs/swagger.json

Requirements

  • Python 3.7+
  • requests
  • mcp (Model Context Protocol)
  • playwright (for advanced web scraping capabilities)

Development

Setup

  • Clone the repository:
git clone <repository-url>
cd swagger_api
  • Install dependencies:
pip install -r requirements.txt
  • Run the server:
python swagger_api/swagger_api.py

Project Structure

swagger_api/
├── __init__.py
├── swagger_api.py      # Main MCP server implementation
├── README.md           # This file
└── requirements.txt    # Python dependencies

Error Handling

The server includes comprehensive error handling:

  • Network Errors: Handles connection issues.
  • JSON Parsing: Graceful handling of malformed JSON responses
  • HTTP Status Codes: Proper error reporting for failed requests
  • SSL Verification: Disabled for internal corporate environments

Security Considerations

  • SSL verification is disabled (verify=False) for internal corporate APIs
  • No authentication tokens are stored in the codebase

Contributing

  • Fork the repository
  • Create a feature branch
  • Make your changes
  • Add tests if applicable
  • Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support and questions, please contact the development team or create an issue in the repository.

Changelog

Version 1.0.0

  • Initial release
  • Support for DCC Notifications API
  • Support for Device View API
  • Support for Supply Order API

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts