StockTrim MCP Server
Model Context Protocol (MCP) server for StockTrim Inventory Management.
This server provides AI assistants like Claude with tools to interact with your StockTrim inventory system, enabling natural language queries and operations for product management, customer data, and inventory control.
Features
- Product Management: Create, retrieve, update, and delete products with full lifecycle support
- Customer Operations: Access and manage customer data
- Supplier Management: Manage supplier information and relationships
- Inventory Control: Set and update inventory levels across locations
- Purchase Orders: Create and manage purchase orders with line items
- Sales Orders: Track and manage sales orders
- Workflow Tools: High-level business operations (forecast management, urgent orders)
- Safety Features: User confirmation for destructive operations via MCP elicitation (ADR 001)
- Service Layer Architecture: Clean separation of business logic with dependency injection
- Type-Safe: Full type hints with Pydantic validation for all operations (ADR 002)
- Production-Ready: Built-in error handling, logging, and resilience
- FastMCP: Built on FastMCP v3 for high-performance MCP implementation
Installation
Using UV (Recommended)
# Install from workspace
cd stocktrim-openapi-client
uv sync --all-extras
# Run server
uvx --from . stocktrim-mcp-server
Using Pip
pip install stocktrim-mcp-server
stocktrim-mcp-server
Configuration
The server requires StockTrim API credentials via environment variables:
Environment Variables
Create a .env file in your project root or set these in your environment:
# Required
STOCKTRIM_API_AUTH_ID=your_tenant_id_here
STOCKTRIM_API_AUTH_SIGNATURE=your_tenant_name_here
# Optional
STOCKTRIM_BASE_URL=https://api.stocktrim.com # Default
Getting Your Credentials
- Log in to your StockTrim account
- Navigate to Settings → API Settings
- Copy your Tenant ID (use as
STOCKTRIM_API_AUTH_ID) - Copy your Tenant Name (use as
STOCKTRIM_API_AUTH_SIGNATURE)
Claude Desktop Integration
Recommended: install the .mcpb bundle — Claude Desktop has built-in support for
MCP Bundles, which install local MCP servers in
one click and prompt for the API credentials via UI (no JSON editing).
- Download
stocktrim-mcp-server-<version>.mcpbfrom the latest GitHub release. - Drag the
.mcpbfile into Claude Desktop, or open it from the Finder. - Confirm install in the dialog. Claude Desktop prompts for both your StockTrim Auth ID (Tenant ID) and Auth Signature (Tenant Name); both are stored securely and never written to a config file by hand.
The bundle ships the server source plus a manifest that declares the runtime requirements; UV handles dep resolution on first launch.
Manual uvx install (fallback)
If you'd rather edit ~/Library/Application Support/Claude/claude_desktop_config.json
(or %APPDATA%\Claude\claude_desktop_config.json on Windows) directly:
{
"mcpServers": {
"stocktrim": {
"command": "uvx",
"args": ["stocktrim-mcp-server"],
"env": {
"STOCKTRIM_API_AUTH_ID": "your_tenant_id_here",
"STOCKTRIM_API_AUTH_SIGNATURE": "your_tenant_name_here"
}
}
}
}
Using Python Environment
If you have the server installed in a specific Python environment:
{
"mcpServers": {
"stocktrim": {
"command": "python",
"args": ["-m", "stocktrim_mcp_server.server"],
"env": {
"STOCKTRIM_API_AUTH_ID": "your_tenant_id_here",
"STOCKTRIM_API_AUTH_SIGNATURE": "your_tenant_name_here"
}
}
}
}
Either path: restart Claude Desktop after configuring and the StockTrim tools will appear.
Available Tools
Product Tools
get_product
Get detailed information about a specific product by code.
Parameters:
code(string, required): Product code to retrieve
Returns: ProductInfo object with code, description, pricing, and status
Example Claude prompt:
Get product information for code "WIDGET-001"
search_products
Search for products by code prefix.
Parameters:
prefix(string, required): Product code prefix to search for
Returns: List of matching products
Example Claude prompt:
Find all products starting with "WIDGET"
Customer Tools
get_customer
Get detailed information about a specific customer by code.
Parameters:
code(string, required): Customer code to retrieve
Returns: CustomerInfo object with code, name, contact information
Example Claude prompt:
Show me customer CUST-001
list_customers
List all customers in the system.
Parameters:
limit(integer, optional): Maximum number of customers to return (default: 50)
Returns: List of customers
Example Claude prompt:
List the first 20 customers
Inventory Tools
set_product_inventory
Update inventory levels for a product.
Parameters:
product_id(string, required): Product ID to updatestock_on_hand(number, optional): Current stock quantitystock_on_order(number, optional): Quantity on orderlocation_code(string, optional): Location codelocation_name(string, optional): Location name
Returns: Operation result with success status
Example Claude prompt:
Set inventory for product 123 to 50 units on hand and 100 on order at location WAREHOUSE-A
Example Conversations
Product Discovery
You: What products do we have starting with "WID"?
Claude: Using search_products("WID")...
Found 3 products:
- WIDGET-001: Standard Widget ($10.00)
- WIDGET-002: Premium Widget ($15.00)
- WIDGET-SPECIAL: Custom Widget ($25.00)
Inventory Management
You: Update inventory for product 123 - we have 75 units in the main warehouse
Claude: Using set_product_inventory(product_id="123", stock_on_hand=75, location_code="MAIN")...
Successfully updated inventory for product 123. Stock on hand is now 75 units.
Customer Lookup
You: Get contact information for customer ACME-001
Claude: Using get_customer("ACME-001")...
Customer: ACME Corporation
Email: contact@acme.com
Phone: +1-555-0123
Address: 123 Main St, City, ST 12345
Development
Running Locally
# Clone repository
git clone https://github.com/dougborg/stocktrim-openapi-client.git
cd stocktrim-openapi-client
# Install dependencies
uv sync --all-extras
# Set environment variables
export STOCKTRIM_API_AUTH_ID=your_tenant_id
export STOCKTRIM_API_AUTH_SIGNATURE=your_tenant_name
# Run server
uv run stocktrim-mcp-server
Project Structure
stocktrim_mcp_server/
├── src/stocktrim_mcp_server/
│ ├── __init__.py # Package metadata
│ ├── server.py # FastMCP server setup
│ └── tools/ # Tool implementations
│ ├── __init__.py # Tool registration
│ ├── products.py # Product management tools
│ ├── customers.py # Customer management tools
│ └── inventory.py # Inventory management tools
├── pyproject.toml # Package configuration
└── README.md # This file
Adding New Tools
- Create a new file in
src/stocktrim_mcp_server/tools/ - Define your tool functions with type hints
- Use the
@unpack_pydantic_paramsdecorator for parameter flattening - Create a
register_tools(mcp: FastMCP)function - Import and call in
tools/__init__.py
See existing tools for examples.
Parameter Flattening Pattern
All tools use a parameter flattening decorator to expose Pydantic model fields as individual tool parameters. This provides better MCP client compatibility while maintaining type safety.
Example Tool Implementation:
from typing import Annotated
from fastmcp import Context
from pydantic import BaseModel, Field
from stocktrim_mcp_server.unpack import Unpack, unpack_pydantic_params
class SearchProductsRequest(BaseModel):
"""Request model for searching products."""
search_query: str = Field(..., description="Search query for product name or code")
limit: int = Field(10, description="Maximum number of results")
class SearchProductsResponse(BaseModel):
"""Response containing matching products."""
products: list[ProductInfo]
total_count: int
@unpack_pydantic_params
async def search_products(
request: Annotated[SearchProductsRequest, Unpack()],
context: Context
) -> SearchProductsResponse:
"""Search for products by name or code.
This tool searches across product fields using keyword matching.
"""
# Inside the function, 'request' is a validated SearchProductsRequest instance
services = get_services(context)
results = await services.products.search(request.search_query, request.limit)
return SearchProductsResponse(products=results, total_count=len(results))
What FastMCP Sees:
# Tool signature exposed to MCP clients:
search_products(
search_query: str, # From SearchProductsRequest.search_query
limit: int = 10, # From SearchProductsRequest.limit
context: Context
) -> SearchProductsResponse
Benefits:
- ✅ MCP Compatibility: Flat parameters work reliably with Claude Code and other clients
- ✅ Type Safety: Pydantic validation ensures parameter correctness
- ✅ Clean Code: Tool implementations work with typed model instances
- ✅ Auto Documentation: Field descriptions become parameter documentation
See Also: ADR 0001: Parameter Flattening
Logging
The server logs to standard output with INFO level by default. Logs include:
- Server lifecycle events (startup, shutdown)
- Tool invocations
- API call results
- Error details
To adjust log level:
# Set environment variable
export LOG_LEVEL=DEBUG
uv run stocktrim-mcp-server
Troubleshooting
Authentication Errors
ValueError: STOCKTRIM_API_AUTH_ID environment variable is required
Solution: Ensure both STOCKTRIM_API_AUTH_ID and STOCKTRIM_API_AUTH_SIGNATURE are
set in your environment or .env file.
Connection Failures
Failed to initialize StockTrimClient: Connection refused
Solution:
- Check that
STOCKTRIM_BASE_URLis correct (default: https://api.stocktrim.com) - Verify your network connection
- Ensure StockTrim API is accessible
Tool Not Found
Tool 'xyz' not found
Solution: Restart Claude Desktop after updating configuration.
Security Notes
- Never commit
.envfiles or expose API credentials in code - Use environment variables for credential management
- Consider using a secrets manager in production environments
- Credentials are passed to StockTrim API via secure HTTPS headers
- Client includes automatic retry logic with exponential backoff
Support
- Issues: GitHub Issues
- Documentation: Client Documentation
- StockTrim API: API Documentation
License
MIT License - see LICENSE file for details
Related Projects
- stocktrim-openapi-client: Python client library for StockTrim API
- FastMCP: High-performance MCP server framework
Changelog
v0.1.0 (2025-10-29)
- Initial release
- Product management tools (get, search)
- Customer management tools (get, list)
- Inventory management tools (set levels)
- Claude Desktop integration
- FastMCP-based implementation
Metadata
Release files for stocktrim-mcp-server 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| stocktrim_mcp_server-0.17.0.tar.gz | 180.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stocktrim_mcp_server-0.17.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 270.2 kB
Release files / stocktrim_mcp_server-0.17.0.tar.gz
| Download URL | stocktrim_mcp_server-0.17.0.tar.gz |
|---|---|
| Size | 180.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35a5f148782f8aff07fa50825bb5999c754c8f403a64167f6a8fbc8f25aba3f0
|
|
BLAKE2b-256 checksum How to use checksums |
b70009f558aace2b970d59b36359ff4b0462029ed91da40b7152d6c350e229dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logRelease files / stocktrim_mcp_server-0.17.0-py3-none-any.whl
| Download URL | stocktrim_mcp_server-0.17.0-py3-none-any.whl |
|---|---|
| Size | 89.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92208b5c8671369f1363b9829e0a79f636ad6384d76eb95e1d615dc5c75945fc
|
|
BLAKE2b-256 checksum How to use checksums |
1653710c939b833061af84ffd0996aa65f0a37e09c2e4bd19c8ad8866b4c7c31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logSecurity for stocktrim-mcp-server 0.17.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for stocktrim_mcp_server-0.17.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.