A Model Context Protocol (MCP) server for querying vCosmos Test Logic API - Units Under Test (UUTs) and tasks
Project description
vCosmos UUT MCP Server
A Model Context Protocol (MCP) server that provides tools to query Units Under Test (UUTs) and tasks from the vCosmos Test Logic API using the official MCP Python library.
🎯 Overview
This production-ready MCP server exposes vCosmos API functionality to MCP clients (like VS Code, Claude, etc.), allowing them to:
- Query UUTs with comprehensive filtering options (pool, site, status, product, health, etc.)
- Query vCosmos tasks with filtering and sorting capabilities
- Get data in optimized flat JSON format for LLM consumption
- Support for sorting and pagination
🏗️ Architecture
graph TD
A[MCP Client<br/>VS Code, Claude, etc.] -->|MCP Protocol<br/>JSON-RPC over stdio| B[vCosmos MCP Server]
subgraph B[vCosmos MCP Server]
C[MCP Tools<br/>• query_vcosmos_uuts<br/>• query_vcosmos_tasks]
D[VCosmosAPIClient Class<br/>built-in HTTP client]
end
B -->|HTTPS/REST| E[vCosmos Test Logic API<br/>https://vcosmos.hpcloud.hp.com/api/tl]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#fff3e0
style D fill:#fff3e0
style E fill:#e8f5e8
🔧 Available Tools
query_vcosmos_uuts
Query vCosmos test devices (UUT) with comprehensive filtering and sorting options.
Parameters:
pool(optional): Device pool IDid(optional): UUT IDsite(optional): Site nameip(optional): IP addressstatus(optional): Device statusinternal_product_name(optional): Internal product namemarketing_product_name(optional): Marketing product namephase(optional): Product phaserelease_year(optional): Release yearlimit(optional, default: 25): Return result count limit (1-5000)health_status(optional): Health status (Healthy, Unhealthy, Offline, Unregistered)sort_by(optional, default: "id"): Sort fieldsort_direction(optional, default: "asc"): Sort direction (asc, desc)
Returns:
- Flat JSON array of UUT objects with fields like: id, hostname, serial_number, site, ip_address, status, product_name, health_status, etc.
query_vcosmos_tasks
Query vCosmos tasks with filtering and sorting capabilities.
Parameters:
status(optional): Task status filter (Waiting, Pending, Running, Done, etc.)result_status(optional): Result status filter (PASS, FAIL, None, etc.)site(optional): Site name filterjob_id(optional): Job ID filterexecutor(optional): Executor filteruut_serial_number(optional): UUT serial number filterlimit(optional, default: 25): Task count limit (1-50)sort_by(optional, default: "createdAt"): Sort fieldsort_direction(optional, default: "desc"): Sort direction (asc, desc)
Returns:
- Flat JSON array of task objects with fields like: id, job_id, status, result_status, finished_at, uut_serial_number
🚀 Quick Start
Prerequisites
- Python 3.8+
- Official MCP Python library
- Valid vCosmos authentication token
Installation
-
Install dependencies:
uv add mcp
-
Set your authentication token:
# PowerShell $env:VCOSMOS_TOKEN = "your_token_here" # Linux/Mac export VCOSMOS_TOKEN="your_token_here"
-
Run the server:
python vcosmos_mcp_server.py
VS Code Integration
Add this configuration to your VS Code MCP settings:
{
"mcpServers": {
"vcosmos": {
"command": "python",
"args": ["d:/Dev/thin_mcp/vcosmos_mcp_server.py"],
"env": {
"VCOSMOS_TOKEN": "your_token_here"
}
}
}
}
📋 Current Implementation
The current implementation (vcosmos_mcp_server.py) is a production-ready MCP server that includes:
- ✅ Official MCP Library: Uses the official MCP Python library
- ✅ Async Implementation: Full async/await support
- ✅ stdio Transport: JSON-RPC over stdio communication
- ✅ Two Main Tools:
query_vcosmos_uutsandquery_vcosmos_tasks - ✅ Comprehensive Filtering: Multiple filter options for both UUTs and tasks
- ✅ Flat JSON Output: Optimized for LLM consumption
- ✅ Error Handling: Robust error handling and validation
- ✅ Built-in HTTP Client: No external dependencies except MCP library
Example Usage
Query UUTs by site:
{
"tool": "query_vcosmos_uuts",
"arguments": {
"site": "hp-tnn-prd",
"limit": 10,
"health_status": "Healthy"
}
}
Query recent failed tasks:
{
"tool": "query_vcosmos_tasks",
"arguments": {
"result_status": "FAIL",
"limit": 5,
"sort_by": "createdAt",
"sort_direction": "desc"
}
}
🔮 Features
UUT Query Features
- Filter by pool, site, IP, status, product names, phase, release year
- Health status filtering (Healthy, Unhealthy, Offline, Unregistered)
- Sorting by various fields (id, site, ip, status, etc.)
- Pagination with configurable limits (1-5000)
- Flat JSON output with clean field names
Task Query Features
- Filter by status, result status, site, job ID, executor
- UUT serial number filtering
- Sort by creation date, status, executor, etc.
- Pagination with configurable limits (1-50)
- Extracts UUT serial numbers and result statuses
Data Format
All responses are in flat JSON format optimized for LLM processing:
UUT Response Example:
[
{
"id": "6710bdbdf3e08f001a43b627",
"hostname": "test-hostname",
"serial_number": "8CC1180BC4",
"site": "hp-tnn-prd",
"ip_address": "15.37.194.115",
"status": "Idle",
"product_name": "HP EliteDesk 800 G8",
"health_status": "Healthy",
"last_updated": "2025-08-22T13:45:54.377Z"
}
]
Task Response Example:
[
{
"id": "68a955a3a5e663f2cca2e788",
"job_id": "job123",
"status": "Running",
"result_status": "PASS",
"finished_at": "2025-08-23T10:30:00Z",
"uut_serial_number": "000277072S"
}
]
📁 File Structure
d:\Dev\thin_mcp\
├── vcosmos_mcp_server.py # ✅ Production MCP Server (main file)
├── main.py # ✅ Original working script
├── vcosmos_client.py # ✅ Legacy VCosmosAPI client module
├── README.md # ✅ Main project documentation
└── README_MCP.md # ✅ This MCP server documentation
🧪 Testing the Server
You can test the server functionality by running it directly and checking the logs:
# Run the server and check startup logs
python vcosmos_mcp_server.py
# The server will show:
# INFO - Starting vCosmos MCP Server (using MCP library)
# INFO - VCOSMOS_TOKEN configured
For integration testing with MCP clients, configure the server in your MCP client and test the tools through the client interface.
🎯 Integration with MCP Clients
This server is ready for integration with:
- VS Code: Through MCP extensions and settings configuration
- Claude: Through MCP protocol support
- Custom Applications: Any application supporting the MCP standard
🔒 Security Notes
- The server uses the
VCOSMOS_TOKENenvironment variable for authentication - Built-in HTTP client with proper timeout handling (30 seconds)
- No credentials are stored in the code
- All API communication uses HTTPS
🐛 Troubleshooting
-
"VCOSMOS_TOKEN environment variable not set":
- Set the environment variable with your vCosmos API token
- Verify the token has the correct permissions
-
"Request error" or API failures:
- Check your network connection to vcosmos.hpcloud.hp.com
- Verify your token is valid and not expired
- Check if the vCosmos API endpoints are accessible
-
"Tool execution error":
- Check the server logs for detailed error messages
- Validate your tool parameters match the schema
- Ensure limit values are within the allowed ranges
-
Empty results
[]:- Check if there are UUTs/tasks matching your filter criteria
- Try broader filter parameters or remove filters to see all data
- Verify your token has access to the requested site/pool
⚡ Performance Notes
- UUT queries support up to 5000 results per request
- Task queries support up to 50 results per request
- Built-in request timeout of 30 seconds
- Flat JSON output optimized for LLM token efficiency
- Minimal memory footprint with direct field extraction
This production-ready MCP server provides a robust bridge between your vCosmos infrastructure and AI/automation tools! 🚀
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vcosmos_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: vcosmos_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89dc1cb5ba6ef548514f8b93728c0af592260713fc6ac429a98b801c08c57ab7
|
|
| MD5 |
2868f2f41ff331b94c469ff66a131ead
|
|
| BLAKE2b-256 |
76de0d001105d19b83011bfab0d9a53ebbbdd5a78461227466be3619ae979be8
|
File details
Details for the file vcosmos_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vcosmos_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2398e70bd11c1359202ccb3035b5829ee60927c7dc3d0f06a694af5bdf66fc64
|
|
| MD5 |
46d1d22f21c45f09834585d3f6432785
|
|
| BLAKE2b-256 |
450c85694d683a05be63544df6444c57f3458af8863f6855e8bd6c9325f5d626
|