Petstore MCP Server & Client
An MCP server and client implementation for the Swagger Petstore API.
Documentation
Petstore MCP Server & Client
A comprehensive Model Context Protocol (MCP) implementation for the Swagger Petstore API. This project includes both a complete MCP server and a sophisticated client system for seamless agent integration.
Overview
This project provides:
- MCP Server: Complete implementation of all Petstore API endpoints
- MCP Client: High-level client with agent-friendly interfaces
- Agent Integration: Ready-to-use components for AI agents
- Configuration Management: Flexible configuration system
- Prompt Templates: Pre-built prompts for different scenarios
Project Structure
petstore/
├── openapi.yaml # OpenAPI 3.0 specification
├── petstore-mcp-server.py # MCP server implementation
├── petstore_mcp_client.py # Comprehensive MCP client
├── agent_interface.py # High-level agent interface
├── transport.py # MCP transport layer
├── prompt_manager.py # Prompt template management
├── sampling.py # AI model sampling configurations
├── client_config.py # Configuration management
├── requirements.txt # Server dependencies
├── client_requirements.txt # Client dependencies
├── mcp-server-config.json # MCP server configuration
├── example_usage.py # Usage examples
├── test_server.py # Server testing script
├── setup.sh # Setup script
└── README.md # This documentation
MCP Server
Features
The MCP server provides comprehensive access to the Petstore API with 19 tools across three categories:
Pet Management (8 tools)
- add_pet: Add a new pet to the store
- update_pet: Update an existing pet
- get_pet_by_id: Find pet by ID
- find_pets_by_status: Find pets by status (available, pending, sold)
- find_pets_by_tags: Find pets by tags
- update_pet_with_form: Update a pet using form data
- delete_pet: Delete a pet
- upload_pet_image: Upload an image for a pet
Store Operations (4 tools)
- get_inventory: Get pet inventories by status
- place_order: Place an order for a pet
- get_order_by_id: Find purchase order by ID
- delete_order: Delete purchase order by ID
User Management (7 tools)
- create_user: Create a new user
- create_users_with_list: Create multiple users from a list
- login_user: Log user into the system
- logout_user: Log out current user session
- get_user_by_name: Get user by username
- update_user: Update user information
- delete_user: Delete a user
Server Installation
-
Install server dependencies:
pip3 install -r requirements.txt -
Make the server executable:
chmod +x petstore-mcp-server.py -
Or run the setup script:
bash setup.sh