partsbox_mcp

nickweedon/partsbox_mcp

3.2

If you are the rightful owner of partsbox_mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A Model Context Protocol (MCP) server for the PartsBox API using FastMCP, enabling AI assistants to interact with PartsBox inventory management system.

PartsBox MCP Server

A Model Context Protocol (MCP) server for the PartsBox API using FastMCP. This server enables AI assistants to interact with your PartsBox inventory management system for electronic components.

Overview

PartsBox is an inventory management system for electronic components. This MCP server provides tools to:

  • Manage parts and their metadata
  • Track stock levels and locations
  • Handle lots and stock entries
  • Manage storage locations
  • Work with projects and BOMs (Bill of Materials)
  • Process orders and receive stock

Requirements

  • Python 3.10+
  • uv package manager
  • PartsBox API key (generated in Settings | Data)

Setup

1. Install dependencies

uv sync

2. Set up environment variables

Create a .env file in the project root:

PARTSBOX_API_KEY=partsboxapi_your_api_key_here

Security Note: Guard your API key carefully, as it provides full access to your PartsBox database.

Environment Variables
VariableDefaultDescription
PARTSBOX_API_KEY(required)Your PartsBox API key
PARTSBOX_MCP_DEBUGtrueEnable timing/logging middleware
PARTSBOX_MCP_MASK_ERRORSfalseHide internal error details from clients
PARTSBOX_BLOB_STORAGE_ROOT/mnt/blob-storagePath to shared storage directory for resource files
PARTSBOX_BLOB_STORAGE_MAX_SIZE_MB100Maximum file size in MB for blob storage
PARTSBOX_BLOB_STORAGE_TTL_HOURS24Default time-to-live in hours for stored blobs

3. Run the server

uv run python partsbox_mcp_server.py

API Overview

The PartsBox API is operation-oriented (not REST) and provides:

Parts Management

  • Create, retrieve, update, and delete parts
  • Manage substitutes and meta-parts
  • Handle custom fields

Stock Management

  • Add and remove stock
  • Move stock between locations
  • Update stock entries
  • Retrieve stock by part or storage location

Lots

  • Get and update lot data
  • Track lot information

Storage

  • Manage storage locations
  • Archive and restore locations
  • Aggregate stock by location

Projects

  • Create and manage BOMs
  • Handle BOM entries
  • Track project builds

Orders

  • Create and manage orders
  • Add order entries
  • Receive stock from orders
  • Manage order lifecycle

Available Tools

Parts API

ToolDescription
list_partsList all parts with pagination and JMESPath queries
get_partGet detailed information for a specific part
create_partCreate a new part
update_partUpdate an existing part
delete_partDelete a part
add_meta_part_idsAdd members to a meta-part
remove_meta_part_idsRemove members from a meta-part
add_substitute_idsAdd substitutes to a part
remove_substitute_idsRemove substitutes from a part
get_part_storageGet aggregated stock by storage location
get_part_lotsGet individual lot entries for a part
get_part_stockGet total stock count for a part

Stock API

ToolDescription
add_stockAdd stock to inventory
remove_stockRemove stock from inventory
move_stockMove stock between locations
update_stockUpdate a stock entry

Lots API

ToolDescription
list_lotsList all lots
get_lotGet lot details
update_lotUpdate lot information

Storage API

ToolDescription
list_storage_locationsList all storage locations
get_storage_locationGet storage location details
update_storage_locationUpdate storage location metadata
rename_storage_locationRename a storage location
change_storage_settingsModify storage settings (full, single-part, existing-parts-only)
archive_storage_locationArchive a storage location
restore_storage_locationRestore an archived location
list_storage_partsList aggregated stock by part in a location
list_storage_lotsList individual lots in a location

Projects API

ToolDescription
list_projectsList all projects/BOMs
get_projectGet project details
create_projectCreate a new project
update_projectUpdate project metadata
delete_projectDelete a project
archive_projectArchive a project
restore_projectRestore an archived project
get_project_entriesGet BOM entries for a project
add_project_entriesAdd entries to a project BOM
update_project_entriesUpdate BOM entries
delete_project_entriesRemove entries from a BOM
get_project_buildsGet build history for a project
get_buildGet build details
update_buildUpdate build information

Orders API

ToolDescription
list_ordersList all orders
get_orderGet order details
create_orderCreate a new order
get_order_entriesGet line items in an order
add_order_entriesAdd items to an order
delete_order_entryRemove an item from an order
receive_orderProcess received inventory

Files API

ToolDescription
get_imageDownload a part image for display (with optional resizing)
get_image_infoGet metadata about an image without downloading
get_image_size_estimateEstimate dimensions and size after resizing
get_fileDownload a file (datasheet, image, etc.)
get_file_urlGet the download URL for a file
get_image_resourceStore image in shared storage and return resource identifier
get_file_resourceStore file in shared storage and return resource identifier

MCP Resources

Resources provide read-only access to files and images via URI templates:

Resource URIDescription
partsbox://image/{file_id}Download and render part images directly in Claude Desktop
partsbox://file/{file_id}Download files (datasheets, PDFs, etc.)
partsbox://file-url/{file_id}Get the download URL without fetching the file

The file_id is obtained from part data (e.g., the part/img-id field returned by get_part or list_parts).

Shared Resource Storage

The server provides resource-based file storage methods (get_image_resource and get_file_resource) that enable sharing files with other MCP servers through a mapped Docker volume. This is useful for multi-container workflows where files need to be passed between services.

How It Works

  1. Files are downloaded from PartsBox and stored in a shared blob storage directory
  2. Each file gets a unique resource identifier (format: blob://TIMESTAMP-HASH.EXT)
  3. Other MCP servers can access these files directly from the mapped volume using the identifier
  4. Files are automatically deduplicated using SHA256 hashing
  5. Files expire after a configurable TTL (default: 24 hours)

Configuration

Configure shared storage using environment variables:

VariableDefaultDescription
PARTSBOX_BLOB_STORAGE_ROOT/mnt/blob-storagePath to shared storage directory
PARTSBOX_BLOB_STORAGE_MAX_SIZE_MB100Maximum file size in MB
PARTSBOX_BLOB_STORAGE_TTL_HOURS24Default time-to-live in hours

Docker Volume Setup

To enable resource sharing between MCP servers, mount a shared volume:

# docker-compose.yml
version: '3.8'
services:
  partsbox-mcp:
    image: partsbox-mcp:latest
    volumes:
      - blob-storage:/mnt/blob-storage
    environment:
      - PARTSBOX_BLOB_STORAGE_ROOT=/mnt/blob-storage

  other-mcp-server:
    image: other-mcp:latest
    volumes:
      - blob-storage:/mnt/blob-storage

volumes:
  blob-storage:

Usage Example

# Store an image in shared storage
response = get_image_resource("img_resistor_10k")
# Returns: ResourceResponse(
#   success=True,
#   resource_id="blob://1733437200-a3f9d8c2b1e4f6a7.png",
#   filename="img_resistor_10k.png",
#   mime_type="image/png",
#   size_bytes=65536,
#   sha256="a3f9d8c2...",
#   expires_at="2024-12-08T12:00:00Z"
# )

# Other MCP servers can now access the file at:
# /mnt/blob-storage/17/33/blob://1733437200-a3f9d8c2b1e4f6a7.png

JMESPath Query Support

All list operations support JMESPath queries for filtering and projection. This server extends standard JMESPath with custom functions for safe null handling and data transformation:

Custom Functions

FunctionDescriptionExample
nvl(value, default)Returns default if value is nullnvl("part/name", '')
int(value)Converts to integer (null on failure)int("custom-field/qty")
str(value)Converts any value to stringstr("part/id")
regex_replace(pattern, repl, value)Regex find-and-replaceregex_replace('[^0-9]', '', "value")

Null-Safe Queries

IMPORTANT: Many PartsBox fields are nullable. Use nvl() to prevent errors when filtering on these fields:

# UNSAFE - fails if "part/name" is null
query="[?contains(\"part/name\", 'resistor')]"

# SAFE - handles null values
query="[?contains(nvl(\"part/name\", ''), 'resistor')]"

Query Examples

# Search parts by name (null-safe)
query="[?contains(nvl(\"part/name\", ''), 'capacitor')]"

# Filter by manufacturer
query="[?nvl(\"part/manufacturer\", '') == 'Texas Instruments']"

# Combine conditions
query="[?contains(nvl(\"part/name\", ''), 'resistor') && \"stock/total\" > `0`]"

# Sort results
query="sort_by(@, &\"part/name\")"

Important Notes

Authentication

All API requests require an API key passed in the Authorization header:

Authorization: APIKey partsboxapi_[your-key]

Timestamps

PartsBox stores timestamps as 64-bit UNIX UTC timestamps. Timezone conversion is your responsibility.

Stock Calculations

PartsBox does not store total stock counts. Stock counts are calculated by traversing stock history.

Rate Limiting

Rate limits may be enforced. Plan for potential rate limiting in your usage.

API Restrictions

  • Cannot create user interface applications using the API (automation only)
  • Commercial plan users receive standard support
  • Free account users should not expect email responses

Claude Integration

This MCP server works with Claude Desktop and Claude Code (CLI). See for detailed configuration instructions.

Related Resources

Developing

This project is designed to work with vscode and the devcontainers plugin. I recommend also running claude --dangerously-skip-permissions once inside the devcontainer for best results 😁