mcp-bundler
v1.2.5
Published
MCPB (MCP Bundle) bundler for Smithery MCP servers
Downloads
35
Readme
MCP Bundler
A tool for bundling Smithery MCP servers into MCPB (MCP Bundle) format for easy distribution and deployment.
Features
- Smithery Integration: Reads
smithery.yamlconfiguration files - MCPB Compliance: Generates MCPB-compliant bundles with proper manifest
- Smart Configuration: Converts Smithery config schemas to MCPB user config format
- Type Safety: Proper JSON Schema to MCPB type mapping
- Nested Config Support: Flattens nested configurations using dot notation
- Automatic Detection: Smart entry point detection and TypeScript support
- Optimized Builds: Minification, tree-shaking, and Node.js built-in externals
Installation
npm install @mcps/bundlerOr use directly:
npx @mcps/bundler <project-name>Usage
CLI
# Bundle a project
mcp-bundler mcp-shrimp-task-manager
# With options
mcp-bundler my-server --minify=false --entry=src/main.tsProgrammatic API
import { bundleMCPServer } from '@mcps/bundler';
const result = await bundleMCPServer(
'/path/to/project',
'/path/to/output',
{
minify: true,
entry: 'src/index.ts'
}
);
console.log(`Bundle created: ${result.outputDir} (${result.bundleSize}KB)`);Configuration
The bundler reads smithery.yaml files and converts them to MCPB format:
Input (smithery.yaml)
startCommand:
configSchema:
type: object
properties:
dataDir:
type: string
description: Directory for data storage
auth:
type: object
properties:
apiKey:
type: string
description: API key for authentication
required: [dataDir]Output (manifest.json)
{
"manifest_version": "0.2",
"name": "my-server",
"version": "1.0.0",
"user_config": {
"dataDir": {
"type": "directory",
"title": "Data Dir",
"description": "Directory for data storage",
"required": true
},
"auth.apiKey": {
"type": "string",
"title": "Auth API Key",
"description": "API key for authentication",
"sensitive": true
}
},
"server": {
"type": "node",
"entry_point": "server.cjs",
"mcp_config": {
"command": "node",
"args": ["${__dirname}/server.cjs"],
"env": {
"DATADIR": "${user_config.dataDir}",
"AUTH_API_KEY": "${user_config.auth.apiKey}"
}
}
}
}Features
Smart Type Conversion
- Automatically detects directory/path fields
- Maps JSON Schema types to MCPB types
- Handles sensitive fields (passwords, keys, tokens)
- Supports validation constraints (min/max for numbers)
Dot Notation Flattening
- Converts nested objects to flat dot notation
auth.apiKeybecomesAUTH_API_KEYenvironment variable- Generates user-friendly titles:
auth.apiKey→ "Auth API Key"
Build Optimization
- Minification enabled by default
- Tree-shaking for smaller bundles
- Node.js built-ins marked as external
- TypeScript support with automatic tsconfig detection
Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| minify | boolean | true | Enable minification |
| entry | string | auto-detect | Override entry point |
Output Structure
project-name.mcpb/
├── server.cjs # Bundled executable server
└── manifest.json # MCPB manifest with metadataAPI Reference
bundleMCPServer(projectPath, outputDir, options)
Bundles an MCP server project.
Parameters:
projectPath(string): Path to the project directoryoutputDir(string): Output directory for the bundleoptions(object): Bundle options
Returns: Promise resolving to bundle result with outputDir, bundleSize, and warnings.
parseSmitheryYaml(yamlContent)
Parses Smithery YAML configuration.
smitheryConfigToUserConfig(configSchema)
Converts Smithery config schema to MCPB user config format.
smitheryToManifest(smitheryConfig, packageInfo)
Generates MCPB manifest from Smithery config and package info.
Requirements
- Node.js >= 18.0.0
- Valid
smithery.yamlconfiguration file - Valid
package.jsonin project root
License
MIT
