Skip to main content

Model Context Protocol (MCP) server for StockTrim Inventory Management API

Project description

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: Search, retrieve, and manage product information
  • Customer Operations: Access and list customer data
  • Order Management: Create and manage sales orders and purchase orders
  • Inventory Control: Set and update inventory levels
  • Type-Safe: Full TypeScript-like type hints for all operations
  • Production-Ready: Built-in error handling, logging, and resilience
  • FastMCP: Leverages FastMCP 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

  1. Log in to your StockTrim account
  2. Navigate to Settings → API Settings
  3. Copy your Tenant ID (use as STOCKTRIM_API_AUTH_ID)
  4. Copy your Tenant Name (use as STOCKTRIM_API_AUTH_SIGNATURE)

Claude Desktop Integration

To use this MCP server with Claude Desktop, add it to your Claude configuration:

On macOS

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "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"
      }
    }
  }
}

On Windows

Edit %APPDATA%\Claude\claude_desktop_config.json with the same configuration.

Using Python Environment

If you have the server installed in a specific Python environment:

{
  "mcpServers": {
    "stocktrim": {
      "command": "python",
      "args": ["-m", "stocktrim_mcp_server"],
      "env": {
        "STOCKTRIM_API_AUTH_ID": "your_tenant_id_here",
        "STOCKTRIM_API_AUTH_SIGNATURE": "your_tenant_name_here"
      }
    }
  }
}

After configuring, restart Claude Desktop for changes to take effect.

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 update
  • stock_on_hand (number, optional): Current stock quantity
  • stock_on_order (number, optional): Quantity on order
  • location_code (string, optional): Location code
  • location_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

  1. Create a new file in src/stocktrim_mcp_server/tools/
  2. Define your tool functions with type hints
  3. Create a register_tools(mcp: FastMCP) function
  4. Import and call in tools/__init__.py

See existing tools for examples.

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_URL is 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 .env files 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

License

MIT License - see LICENSE file for details

Related Projects

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stocktrim_mcp_server-0.5.0.tar.gz (65.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stocktrim_mcp_server-0.5.0-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file stocktrim_mcp_server-0.5.0.tar.gz.

File metadata

  • Download URL: stocktrim_mcp_server-0.5.0.tar.gz
  • Upload date:
  • Size: 65.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stocktrim_mcp_server-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f0738bb2ffbd3c6e7914835e6d4fc6bd358be9e98e3788f859668cdfa5c2a8ac
MD5 90f0e28faca72561ce4ef2df6ce5eaa2
BLAKE2b-256 52fa3c009389b4bee37a0ebd5cc3105c1745fa7d437d45051d53387749979925

See more details on using hashes here.

Provenance

The following attestation bundles were made for stocktrim_mcp_server-0.5.0.tar.gz:

Publisher: release.yml on dougborg/stocktrim-openapi-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stocktrim_mcp_server-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stocktrim_mcp_server-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c4dd685dd13a69a9dbc5536c08a7e3a692d865576896b9d8fd7bab1cdc0c663
MD5 e9e9e1e4defa389a00ef4e644e76d429
BLAKE2b-256 c700d1e40bea4fad088e07c4cf2d410ffde4023a05f78dc0508f0d3db43a527a

See more details on using hashes here.

Provenance

The following attestation bundles were made for stocktrim_mcp_server-0.5.0-py3-none-any.whl:

Publisher: release.yml on dougborg/stocktrim-openapi-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page