### Quick Start: Init, Pack, and Sign Extension Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md A workflow demonstrating the initial setup and packaging of a new MCPB extension, including optional self-signing. ```bash # 1. Create a new extension directory mkdir my-awesome-extension cd my-awesome-extension # 2. Initialize the extension mcpb init # 3. Follow the prompts to configure your extension # The tool will create a manifest.json with all necessary fields # 4. Create your server implementation based on the entry point you specified # 5. Pack the extension mcpb pack . # 6. (Optional) Sign the extension mcpb sign my-awesome-extension.mcpb --self-signed ``` -------------------------------- ### Development Setup Commands Source: https://github.com/modelcontextprotocol/mcpb/blob/main/README.md Provides the necessary shell commands to set up the development environment for the MCPB project, including cloning the repository, installing dependencies, building the project, and running tests. ```sh # Clone the repository git clone https://github.com/anthropics/mcpb.git cd mcpb # Install dependencies yarn # Build the project yarn build # Run tests yarn test ``` -------------------------------- ### Localization Configuration Example Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md This example shows how to configure localization for user-facing strings by pointing to external resource files. Ensure the resources path includes a ${locale} placeholder. ```json "localization": { "resources": "relative-path-to-resources/${locale}.json", "default_locale": "en-US" } ``` -------------------------------- ### Initialize MCPB Manifest Source: https://github.com/modelcontextprotocol/mcpb/blob/main/README.md Run the 'mcpb init' command in your local MCP server's directory to start the process of creating a manifest.json file. This command guides you through defining the bundle's metadata and capabilities. ```sh mcpb init ``` -------------------------------- ### Example MCPB Manifest Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md This is an example of a basic MCPB manifest file, showing essential fields like protocol version, server information, and tool definitions. ```json { "instructions": "When the user wants to search files, use the search_files tool but only after asking them whether the files are local.", "protocolVersion": "2025-06-18", "serverInfo": { "name": "MyMCPExtension", "title": "My MCP Extension - Pro Edition", "version": "1.0.0" } }, "tools/list": { "tools": [ { "name": "search_files", "title": "File search", "description": "Search for files in a directory", "inputSchema": { "type": "object", "properties": { "fileSpec": { "type": "string", "description": "The file name to search for. Wildcards are supported" } }, "required": ["fileSpec"] }, "outputSchema": { "type": "object", "properties": { "searchResults": { "type": "array", "description": "The list of file paths that were found", "items": { "type": "string" } } } } } ] } } ``` -------------------------------- ### Development Workflow Start Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Initiates the creation of a new extension directory as the first step in a development workflow. ```bash # 1. Create your extension mkdir my-extension cd my-extension ``` -------------------------------- ### Define a full manifest.json Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md A comprehensive example including optional metadata, localization, tools, prompts, and compatibility settings. ```json { "manifest_version": "0.3", "name": "My MCP Extension", "display_name": "My Awesome MCP Extension", "version": "1.0.0", "description": "A brief description of what this extension does", "long_description": "A detailed description that can include multiple paragraphs explaining the extension's functionality, use cases, and features. It supports basic markdown.", "author": { "name": "Your Name", "email": "yourname@example.com", "url": "https://your-website.com" }, "repository": { "type": "git", "url": "https://github.com/your-username/my-mcp-extension.git" }, "homepage": "https://example.com/my-extension", "documentation": "https://docs.example.com/my-extension", "support": "https://github.com/your-username/my-extension/issues", "icon": "icon.png", "icons": [ { "src": "assets/icons/icon-16-light.png", "size": "16x16", "theme": "light" }, { "src": "assets/icons/icon-16-dark.png", "size": "16x16", "theme": "dark" } ], "screenshots": [ "assets/screenshots/screenshot1.png", "assets/screenshots/screenshot2.png" ], "localization": { "resources": "custom-directory-for-mcpb-resources/${locale}.json", "default_locale": "en-US" }, "server": { "type": "node", "entry_point": "server/index.js", "mcp_config": { "command": "node", "args": ["server/index.js"], "env": { "ALLOWED_DIRECTORIES": "${user_config.allowed_directories}" } } }, "tools": [ { "name": "search_files", "description": "Search for files in a directory" } ], "prompts": [ { "name": "poetry", "description": "Have the LLM write poetry", "arguments": ["topic"], "text": "Write a creative poem about the following topic: ${arguments.topic}" } ], "tools_generated": true, "keywords": ["api", "automation", "productivity"], "license": "MIT", "privacy_policies": ["https://example.com/privacy"], "compatibility": { "claude_desktop": ">=1.0.0", "platforms": ["darwin", "win32", "linux"], "runtimes": { "python": ">=3.8", "node": ">=16.0.0" } }, "user_config": { "allowed_directories": { "type": "directory", "title": "Allowed Directories", "description": "Directories the server can access", "multiple": true, "required": true, "default": ["${HOME}/Desktop"] }, "api_key": { "type": "string", "title": "API Key", "description": "Your API key for authentication", "sensitive": true, "required": false }, "max_file_size": { "type": "number", "title": "Maximum File Size (MB)", "description": "Maximum file size to process", "default": 10, "min": 1, "max": 100 } }, "_meta": { "com.microsoft.windows": { "package_family_name": "MyMcpMSIXPackage_51g09708xawrw", "static_responses": { "initialize": { "capabilities": {} ``` -------------------------------- ### Configure user settings in manifest.json Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md An example showing how to define user-configurable settings that can be injected into environment variables. ```json { "manifest_version": "0.3", "name": "my-extension", "version": "1.0.0", "description": "A simple MCP extension", "author": { "name": "Extension Author" }, "server": { "type": "node", "entry_point": "server/index.js", "mcp_config": { "command": "node", "args": ["${__dirname}/server/index.js"], "env": { "API_KEY": "${user_config.api_key}" } } }, "user_config": { "api_key": { "type": "string", "title": "API Key", "description": "Your API key for authentication", "sensitive": true, "required": true } } } ``` -------------------------------- ### Install MCPB CLI Source: https://github.com/modelcontextprotocol/mcpb/blob/main/README.md Install the MCPB CLI globally using npm. This tool assists in creating manifest.json files and packing local MCP servers into .mcpb files. ```sh npm install -g @anthropic-ai/mcpb ``` -------------------------------- ### Sync Dependencies with UV Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/hello-world-uv/README.md Install project dependencies defined in pyproject.toml using uv sync. ```bash uv sync ``` -------------------------------- ### UV extension package structure Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Example file structure for an MCPB extension using the UV runtime. ```text extension.mcpb ├── manifest.json # server.type = "uv" ├── pyproject.toml # Dependencies ├── .mcpbignore # Exclude .venv, server/lib └── src/ └── server.py ``` -------------------------------- ### Configure extension server types Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Examples of manifest configurations for different server types including Python, Node.js, and binary executables. ```json { "server": { "type": "python", "entry_point": "server/main.py" }, "compatibility": { "claude_desktop": ">=0.10.0", "platforms": ["darwin", "win32", "linux"], "runtimes": { "python": ">=3.8,<4.0" } } } ``` ```json { "server": { "type": "node", "entry_point": "server/index.js" }, "compatibility": { "claude_desktop": ">=0.10.0", "platforms": ["darwin"], "runtimes": { "node": ">=16.0.0" } } } ``` ```json { "server": { "type": "binary", "entry_point": "server/my-tool" }, "compatibility": { "claude_desktop": ">=0.10.0", "platforms": ["darwin", "win32"] } } ``` -------------------------------- ### Complete MCPB Manifest Configuration Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt A comprehensive example of an MCPB manifest file including metadata, server configuration, tools, prompts, and user configuration schema. ```json { "manifest_version": "0.4", "name": "advanced-mcp-server", "display_name": "Advanced MCP Server", "version": "2.0.0", "description": "Feature-rich MCP server with full configuration", "long_description": "Detailed description with **markdown** support for extension stores.", "author": { "name": "Acme Inc", "email": "support@acme.com", "url": "https://acme.com" }, "repository": { "type": "git", "url": "https://github.com/acme/mcp-server" }, "homepage": "https://acme.com/mcp-server", "documentation": "https://docs.acme.com/mcp-server", "support": "https://github.com/acme/mcp-server/issues", "icon": "icon.png", "icons": [ { "src": "icons/icon-16-light.png", "size": "16x16", "theme": "light" }, { "src": "icons/icon-16-dark.png", "size": "16x16", "theme": "dark" } ], "server": { "type": "node", "entry_point": "server/index.js", "mcp_config": { "command": "node", "args": [ "${__dirname}/server/index.js", "--workspace=${user_config.workspace}" ], "env": { "API_KEY": "${user_config.api_key}", "DEBUG": "${user_config.debug_mode}" }, "platform_overrides": { "win32": { "env": { "PATH_SEP": "\\" } } } } }, "tools": [ { "name": "search_files", "description": "Search for files by pattern" }, { "name": "read_file", "description": "Read contents of a file" } ], "tools_generated": false, "prompts": [ { "name": "code_review", "description": "Generate a code review", "arguments": ["language", "code"], "text": "Review this ${arguments.language} code:\n\n${arguments.code}" } ], "user_config": { "api_key": { "type": "string", "title": "API Key", "description": "Your API key for authentication", "sensitive": true, "required": true }, "workspace": { "type": "directory", "title": "Workspace Directory", "description": "Directory for file operations", "default": "${HOME}/Documents", "multiple": true, "required": false }, "max_results": { "type": "number", "title": "Max Results", "description": "Maximum number of results to return", "default": 10, "min": 1, "max": 100 }, "debug_mode": { "type": "boolean", "title": "Debug Mode", "description": "Enable verbose logging", "default": false } }, "compatibility": { "claude_desktop": ">=0.10.0", "platforms": ["darwin", "win32", "linux"], "runtimes": { "node": ">=16.0.0" } }, "keywords": ["files", "search", "automation"], "license": "MIT", "privacy_policies": ["https://acme.com/privacy"] } ``` -------------------------------- ### UV Runtime Manifest Configuration Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Example manifest for Python servers utilizing the UV runtime for dependency management. ```json { "manifest_version": "0.4", "name": "python-mcp-server", "version": "1.0.0", "description": "Python MCP server using UV runtime", "author": { "name": "Your Name" }, "server": { "type": "uv", "entry_point": "src/server.py", "mcp_config": { "command": "uv", "args": ["run", "--directory", "${__dirname}", "src/server.py"] } }, "compatibility": { "platforms": ["darwin", "linux", "win32"], "runtimes": { "python": ">=3.10" } } } ``` -------------------------------- ### MCPB Manifest Structure Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Examples of complete MCPB manifests for Node.js and Python servers, showcasing various configuration options. ```APIDOC ## Complete Manifest with All Options A comprehensive manifest demonstrating all available configuration options. ```json { "manifest_version": "0.4", "name": "advanced-mcp-server", "display_name": "Advanced MCP Server", "version": "2.0.0", "description": "Feature-rich MCP server with full configuration", "long_description": "Detailed description with **markdown** support for extension stores.", "author": { "name": "Acme Inc", "email": "support@acme.com", "url": "https://acme.com" }, "repository": { "type": "git", "url": "https://github.com/acme/mcp-server" }, "homepage": "https://acme.com/mcp-server", "documentation": "https://docs.acme.com/mcp-server", "support": "https://github.com/acme/mcp-server/issues", "icon": "icon.png", "icons": [ { "src": "icons/icon-16-light.png", "size": "16x16", "theme": "light" }, { "src": "icons/icon-16-dark.png", "size": "16x16", "theme": "dark" } ], "server": { "type": "node", "entry_point": "server/index.js", "mcp_config": { "command": "node", "args": [ "${__dirname}/server/index.js", "--workspace=${user_config.workspace}" ], "env": { "API_KEY": "${user_config.api_key}", "DEBUG": "${user_config.debug_mode}" }, "platform_overrides": { "win32": { "env": { "PATH_SEP": "\\" } } } } }, "tools": [ { "name": "search_files", "description": "Search for files by pattern" }, { "name": "read_file", "description": "Read contents of a file" } ], "tools_generated": false, "prompts": [ { "name": "code_review", "description": "Generate a code review", "arguments": ["language", "code"], "text": "Review this ${arguments.language} code:\n\n${arguments.code}" } ], "user_config": { "api_key": { "type": "string", "title": "API Key", "description": "Your API key for authentication", "sensitive": true, "required": true }, "workspace": { "type": "directory", "title": "Workspace Directory", "description": "Directory for file operations", "default": "${HOME}/Documents", "multiple": true, "required": false }, "max_results": { "type": "number", "title": "Max Results", "description": "Maximum number of results to return", "default": 10, "min": 1, "max": 100 }, "debug_mode": { "type": "boolean", "title": "Debug Mode", "description": "Enable verbose logging", "default": false } }, "compatibility": { "claude_desktop": ">=0.10.0", "platforms": ["darwin", "win32", "linux"], "runtimes": { "node": ">=16.0.0" } }, "keywords": ["files", "search", "automation"], "license": "MIT", "privacy_policies": ["https://acme.com/privacy"] } ``` ## UV Runtime (Python) Manifest Python servers using UV runtime for automatic dependency management. ```json { "manifest_version": "0.4", "name": "python-mcp-server", "version": "1.0.0", "description": "Python MCP server using UV runtime", "author": { "name": "Your Name" }, "server": { "type": "uv", "entry_point": "src/server.py", "mcp_config": { "command": "uv", "args": ["run", "--directory", "${__dirname}", "src/server.py"] } }, "compatibility": { "platforms": ["darwin", "linux", "win32"], "runtimes": { "python": ">=3.10" } } } ``` ``` -------------------------------- ### Custom Exclusions with .mcpbignore Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Example of a .mcpbignore file specifying custom patterns to exclude during packing. Supports exact matches, globs, and directory paths. ```ignore # .mcpbignore example # Comments start with # *.test.js src/**/*.test.ts coverage/ *.log .env* temp/ docs/ ``` -------------------------------- ### GET tools/list Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Retrieves the list of available tools provided by the MCP extension, including the search_files tool. ```APIDOC ## GET tools/list ### Description Returns a list of tools available for the MCP extension, including their schemas and descriptions. ### Method GET ### Endpoint tools/list ### Response #### Success Response (200) - **tools** (array) - List of available tools #### Response Example { "tools": [ { "name": "search_files", "title": "File search", "description": "Search for files in a directory", "inputSchema": { "type": "object", "properties": { "fileSpec": { "type": "string", "description": "The file name to search for. Wildcards are supported" } }, "required": ["fileSpec"] } } ] } ``` -------------------------------- ### Initialize a New Bundle Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Commands to create a manifest.json file either interactively or with specific flags. ```bash # Interactive initialization in current directory mcpb init # Initialize in a specific directory mcpb init ./my-extension # Non-interactive mode with defaults mcpb init --non-interactive # Specify manifest version mcpb init --manifest-version 0.4 ``` -------------------------------- ### Build the Rust binary Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/calculator-rust/README.md Compile the Rust project and prepare the server directory for packaging. ```bash cd examples/calculator-rust cargo build --release mkdir -p server cp target/release/mcp-calculator server/ ``` -------------------------------- ### Initialize MCPB Extension Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Creates a new MCPB extension manifest interactively. Use without arguments to initialize in the current directory, or provide a directory path to initialize elsewhere. ```bash mcpb init ``` ```bash mcpb init my-extension/ ``` -------------------------------- ### Pack an Extension Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Commands to bundle a directory into a .mcpb file. ```bash # Pack current directory mcpb pack . # Pack with custom output filename mcpb pack ./my-extension my-extension-v1.0.mcpb # Pack with external manifest mcpb pack ./server --manifest ./manifest.json # Expected output: # Validating manifest... # Manifest schema validation passes! # # Archive Contents # 1.2kB manifest.json # 856B server/index.js # 45.3kB node_modules/ [and 142 more files] # # Archive Details # name: my-extension # version: 1.0.0 # package size: 18.2kB # unpacked size: 47.4kB # shasum: a1b2c3d4e5f6... ``` -------------------------------- ### Production Workflow: Sign Extension Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Sign your extension with production certificates. Requires certificate and key files. ```bash mcpb sign my-extension.mcpb \ --cert production-cert.pem \ --key production-key.pem \ --intermediate intermediate-ca.pem root-ca.pem ``` -------------------------------- ### Pack MCPB Project Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/hello-world-uv/README.md Use this command to pack the MCPB project into a deployable file. ```bash mcpb pack ``` -------------------------------- ### Basic Manifest Configuration Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt The minimum required fields for a valid manifest.json file. ```json { "manifest_version": "0.4", "name": "my-mcp-server", "version": "1.0.0", "description": "A simple MCP server that provides time utilities", "author": { "name": "Your Name" }, "server": { "type": "node", "entry_point": "server/index.js", "mcp_config": { "command": "node", "args": ["${__dirname}/server/index.js"] } } } ``` -------------------------------- ### Production Workflow: Pack Extension Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Pack your extension directory for production distribution. ```bash mcpb pack my-extension/ ``` -------------------------------- ### Pack an MCP Bundle Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/README.md Use the dxt CLI tool to package an MCP bundle directory into the MCPB format. ```bash dxt pack examples/hello-world-node ``` -------------------------------- ### Run MCP Server with UV Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/hello-world-uv/README.md Execute the MCP server implementation using uv run. Ensure the path to the server script is correct. ```bash uv run src/server.py ``` -------------------------------- ### Filesystem Extension Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Configures a filesystem server with directory access permissions using user-defined inputs. ```json { "user_config": { "allowed_directories": { "type": "directory", "title": "Allowed Directories", "description": "Select directories the filesystem server can access", "multiple": true, "required": true, "default": ["${HOME}/Desktop", "${HOME}/Documents"] } }, "server": { "mcp_config": { "command": "node", "args": [ "${__dirname}/server/index.js", "${user_config.allowed_directories}" ] } } } ``` -------------------------------- ### Pack the MCP bundle Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/calculator-rust/README.md Create the MCP bundle using the mcpb tool, respecting the .mcpbignore file. ```bash mcpb pack examples/calculator-rust ``` -------------------------------- ### Sign and Verify Extensions Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Commands for managing digital signatures on .mcpb bundles. ```bash # Sign with self-signed certificate (development) mcpb sign my-extension.mcpb --self-signed # Sign with production certificate mcpb sign my-extension.mcpb \ --cert cert.pem \ --key key.pem \ --intermediate intermediate-ca.pem # Verify signature mcpb verify my-extension.mcpb # View extension info mcpb info my-extension.mcpb # Remove signature mcpb unsign my-extension.mcpb ``` -------------------------------- ### Define a basic manifest.json Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md A minimal configuration containing only the required fields for an MCP extension. ```jsonc { "manifest_version": "0.3", // Manifest spec version this manifest conforms to "name": "my-extension", // Machine-readable name (used for CLI, APIs) "version": "1.0.0", // Semantic version of your extension "description": "A simple MCP extension", // Brief description of what the extension does "author": { // Author information (required) "name": "Extension Author", // Author's name (required field) }, "server": { // Server configuration (required) "type": "node", // Server type: "node", "python", or "binary" "entry_point": "server/index.js", // Path to the main server file "mcp_config": { // MCP server configuration "command": "node", // Command to run the server "args": [ // Arguments passed to the command "${__dirname}/server/index.js", // ${__dirname} is replaced with the extension's directory ], }, }, } ``` -------------------------------- ### Node.js Bundle Structure Source: https://github.com/modelcontextprotocol/mcpb/blob/main/README.md Illustrates the file and directory structure for a Node.js MCPB bundle. Includes required manifest.json and optional server files, dependencies, package.json, icon, and assets. ```text bundle.mcpb (ZIP file) ├── manifest.json # Required: Bundle metadata and configuration ├── server/ # Server files │ └── index.js # Main entry point ├── node_modules/ # Bundled dependencies ├── package.json # Optional: NPM package definition ├── icon.png # Optional: Bundle icon └── assets/ # Optional: Additional assets ``` -------------------------------- ### Node.js Server Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Configure an MCP server to run a Node.js script. Dependencies should be in `node_modules` and the runtime version specified. ```json "mcp_config": { "command": "node", "args": ["${__dirname}/server/index.js"], "env": {} } ``` -------------------------------- ### Binary Server Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Configure an MCP server to run a pre-compiled binary. Ensure the binary is self-contained and platform-specific binaries are supported. ```json "mcp_config": { "command": "server/my-server", "args": ["--config", "server/config.json"], "env": {} } ``` -------------------------------- ### Configure UV runtime server Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md The UV server type allows for cross-platform Python extensions without bundling dependencies. ```json { "manifest_version": "0.4", "server": { "type": "uv", "entry_point": "src/server.py" } } ``` -------------------------------- ### Test the MCP binary Source: https://github.com/modelcontextprotocol/mcpb/blob/main/examples/calculator-rust/README.md Perform manual testing of the MCP server using JSON-RPC messages via stdio. ```bash # MCP protocol handshake echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \ | ./server/mcp-calculator # Tool call (printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}\n' printf '{"jsonrpc":"2.0","method":"notifications/initialized"}\n' printf '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"sum","arguments":{"a":3,"b":4}}}\n' sleep 1) | ./server/mcp-calculator ``` -------------------------------- ### POST /api/packExtension Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Packs a directory into a `.mcpb` bundle file. This function is asynchronous and returns a promise that resolves to a boolean indicating success or failure. ```APIDOC ## POST /api/packExtension ### Description Packs a directory into a `.mcpb` bundle file. ### Method POST ### Endpoint /api/packExtension ### Parameters #### Request Body - **extensionPath** (string) - Required - The path to the extension directory to be packed. - **outputPath** (string) - Required - The desired output path for the `.mcpb` bundle file. - **silent** (boolean) - Optional - If true, suppresses console output. Defaults to false. - **manifestPath** (string) - Optional - Path to an external manifest file to use instead of the one found in the extension directory. ### Request Example ```typescript import { packExtension } from "@anthropic-ai/mcpb"; async function createBundle() { const success = await packExtension({ extensionPath: "./my-extension", outputPath: "./dist/my-extension.mcpb", silent: false, // Set true to suppress console output manifestPath: "./custom-manifest.json" // Optional external manifest }); if (success) { console.log("Bundle created successfully!"); } else { console.error("Failed to create bundle"); } } createBundle(); ``` ### Response #### Success Response (200) - **success** (boolean) - true if the bundle was created successfully, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Pack Extension Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Pack your extension directory into an MCPB file. The '.' indicates the current directory. ```bash mcpb pack . my-extension.mcpb ``` -------------------------------- ### Static Tool and Prompt Declaration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Defines a fixed set of tools and prompts for an MCP server manifest. ```json { "tools": [ { "name": "search_files", "description": "Search for files" }, { "name": "read_file", "description": "Read file contents" } ], "prompts": [ { "name": "explain_code", "description": "Explain how code works", "arguments": ["code", "language"], "text": "Please explain the following ${arguments.language} code in detail:\n\n${arguments.code}" } ] } ``` -------------------------------- ### API Integration Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Sets up an API-based server requiring sensitive authentication keys and base URL configuration. ```json { "user_config": { "api_key": { "type": "string", "title": "API Key", "description": "Your API key for authentication", "sensitive": true, "required": true }, "base_url": { "type": "string", "title": "API Base URL", "description": "The base URL for API requests", "default": "https://api.example.com", "required": false } }, "server": { "mcp_config": { "command": "node", "args": ["server/index.js"], "env": { "API_KEY": "${user_config.api_key}", "BASE_URL": "${user_config.base_url}" } } } } ``` -------------------------------- ### Database Connection Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Configures a Python-based database server with file paths, read-only modes, and query timeouts. ```json { "user_config": { "database_path": { "type": "file", "title": "Database File", "description": "Path to your SQLite database file", "required": true }, "read_only": { "type": "boolean", "title": "Read Only Mode", "description": "Open database in read-only mode", "default": true }, "timeout": { "type": "number", "title": "Query Timeout (seconds)", "description": "Maximum time for query execution", "default": 30, "min": 1, "max": 300 } }, "server": { "mcp_config": { "command": "python", "args": [ "server/main.py", "--database", "${user_config.database_path}", "--timeout", "${user_config.timeout}" ], "env": { "READ_ONLY": "${user_config.read_only}" } } } } ``` -------------------------------- ### Binary Bundle Structure Source: https://github.com/modelcontextprotocol/mcpb/blob/main/README.md Details the structure of a Binary MCPB bundle. It must contain manifest.json and server files (executables), with an optional icon. ```text bundle.mcpb (ZIP file) ├── manifest.json # Required: Bundle metadata and configuration ├── server/ # Server files │ ├── my-server # Unix executable │ ├── my-server.exe # Windows executable └── icon.png # Optional: Bundle icon ``` -------------------------------- ### Validate Manifest File Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Validate the manifest.json file for your extension before packing. ```bash mcpb validate manifest.json ``` -------------------------------- ### Python Server Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Configure an MCP server to run a Python script. Ensure the Python runtime is specified and dependencies are bundled. ```json "mcp_config": { "command": "python", "args": ["${__dirname}/server/main.py"], "env": { "PYTHONPATH": "${__dirname}/server/lib" } } ``` -------------------------------- ### Implement an MCP Server in Node.js Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Uses the @modelcontextprotocol/sdk to define tools and handle execution requests via stdio transport. ```javascript #!/usr/bin/env node import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js"; const server = new Server( { name: "my-mcp-server", version: "1.0.0" }, { capabilities: { tools: {} } } ); // Define available tools server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: "get_current_time", description: "Get the current computer time", inputSchema: { type: "object", properties: { timezone: { type: "string", description: "Timezone (e.g., 'America/New_York')" } } } }, { name: "calculate", description: "Perform arithmetic calculation", inputSchema: { type: "object", properties: { expression: { type: "string", description: "Math expression" } }, required: ["expression"] } } ] })); // Handle tool execution server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; switch (name) { case "get_current_time": { const options = { timeZone: args?.timezone || "UTC", dateStyle: "full", timeStyle: "long" }; const time = new Date().toLocaleString("en-US", options); return { content: [{ type: "text", text: `Current time: ${time}` }] }; } case "calculate": { try { // Safe evaluation (use a proper math library in production) const result = Function(`"use strict"; return (${args.expression})`)(); return { content: [{ type: "text", text: `Result: ${result}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } } default: throw new Error(`Unknown tool: ${name}`); } }); // Start server with stdio transport async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("MCP server running..."); } main().catch(console.error); ``` -------------------------------- ### Platform-Specific Binary Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Override MCP server configuration for specific platforms like Windows or macOS. Apps automatically append `.exe` on Windows. ```json "mcp_config": { "command": "server/my-server", "args": ["--config", "server/config.json"], "env": {}, "platform_overrides": { "win32": { "command": "server/my-server.exe", "args": ["--config", "server/config-windows.json"] }, "darwin": { "env": { "DYLD_LIBRARY_PATH": "server/lib" } } } } ``` -------------------------------- ### Python Bundle Structure Source: https://github.com/modelcontextprotocol/mcpb/blob/main/README.md Shows the directory layout for a Python MCPB bundle. Requires manifest.json, and can include server files, Python packages in lib/, a requirements.txt, and an icon. ```text bundle.mcpb (ZIP file) ├── manifest.json # Required: Bundle metadata and configuration ├── server/ # Server files │ ├── main.py # Main entry point │ └── utils.py # Additional modules ├── lib/ # Bundled Python packages ├── requirements.txt # Optional: Python dependencies list └── icon.png # Optional: Bundle icon ``` -------------------------------- ### Pack Directory into MCPB Extension Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Packs a directory into a MCPB extension file. By default, it packs the current directory into 'extension.mcpb'. You can specify a custom output filename. ```bash mcpb pack . ``` ```bash mcpb pack my-extension/ my-extension-v1.0.mcpb ``` -------------------------------- ### Validate a Manifest Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Commands to verify the integrity of a manifest.json file against the schema. ```bash # Validate specific manifest file mcpb validate manifest.json # Validate manifest in directory mcpb validate ./my-extension # Output on success: # Manifest schema validation passes! # Icon validation warnings: # - Icon validation passed. Recommended size is 512x512 pixels... ``` -------------------------------- ### Display MCPB Extension Info Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Displays information about a MCPB extension file, including file size, signature status, and certificate details if signed. ```bash mcpb info my-extension.mcpb ``` -------------------------------- ### Specify compatibility requirements Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md The compatibility object defines client version constraints, supported platforms, and required runtimes. ```json { "compatibility": { "claude_desktop": ">=1.0.0", "my_client": ">1.0.0", "other_client": ">=2.0.0 <3.0.0", "platforms": ["darwin", "win32", "linux"], "runtimes": { "python": ">=3.8", "node": ">=16.0.0" } } } ``` -------------------------------- ### Pack Extension API Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Packs an extension directory into a .mcpb bundle file. The function returns a promise resolving to a success boolean. ```typescript import { packExtension } from "@anthropic-ai/mcpb"; async function createBundle() { const success = await packExtension({ extensionPath: "./my-extension", outputPath: "./dist/my-extension.mcpb", silent: false, // Set true to suppress console output manifestPath: "./custom-manifest.json" // Optional external manifest }); if (success) { console.log("Bundle created successfully!"); } else { console.error("Failed to create bundle"); } } createBundle(); ``` -------------------------------- ### Dynamic Capability Declaration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Uses generated flags to indicate that tools and prompts are discovered at runtime. ```json { "tools": [{ "name": "search", "description": "Search functionality" }], "tools_generated": true, "prompts_generated": true } ``` -------------------------------- ### Sign Extension for Testing Source: https://github.com/modelcontextprotocol/mcpb/blob/main/CLI.md Sign your packed extension using a self-signed certificate for testing purposes. ```bash mcpb sign my-extension.mcpb --self-signed ``` -------------------------------- ### Sign and Verify MCPB Bundles Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Use these functions to manage PKCS#7 signatures for MCPB files. Requires certificate and key files for signing operations. ```typescript import { signMcpbFile, verifyMcpbFile, unsignMcpbFile } from "@anthropic-ai/mcpb/node"; // Sign a bundle with certificate and key signMcpbFile( "./my-extension.mcpb", "./cert.pem", "./key.pem", ["./intermediate.pem"] // Optional intermediate certificates ); // Verify a signed bundle async function checkSignature() { const result = await verifyMcpbFile("./my-extension.mcpb"); console.log("Status:", result.status); // "unsigned" | "self-signed" | "signed" if (result.status !== "unsigned") { console.log("Publisher:", result.publisher); console.log("Issuer:", result.issuer); console.log("Valid from:", result.valid_from); console.log("Valid to:", result.valid_to); console.log("Fingerprint:", result.fingerprint); } } // Remove signature from bundle unsignMcpbFile("./my-extension.mcpb"); ``` -------------------------------- ### Define icon variants Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Use the icons array to provide multiple icon sizes and themes. The size field must follow the WIDTHxHEIGHT format. ```json "icons": [ { "src": "assets/icons/icon-16-light.png", "size": "16x16", "theme": "light" }, { "src": "assets/icons/icon-16-dark.png", "size": "16x16", "theme": "dark" } ] ``` -------------------------------- ### getMcpConfigForManifest Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Generates runtime MCP configuration by performing variable substitution on a manifest. ```APIDOC ## getMcpConfigForManifest ### Description Processes an MCP manifest to generate runtime configuration, substituting variables like `__dirname` and user-provided configuration values. ### Parameters - **manifest** (object) - Required - The manifest object - **extensionPath** (string) - Required - Base path of the extension - **systemDirs** (object) - Required - Map of system directory paths - **userConfig** (object) - Required - User-provided configuration values - **pathSeparator** (string) - Required - Path separator character ### Response - **command** (string) - The command to execute - **args** (string[]) - Arguments for the command - **env** (object) - Environment variables ``` -------------------------------- ### Generate MCP Configuration Source: https://context7.com/modelcontextprotocol/mcpb/llms.txt Generates runtime configuration by substituting variables defined in the manifest with provided user configuration and system paths. ```typescript import { getMcpConfigForManifest } from "@anthropic-ai/mcpb"; async function getConfig() { const manifest = { name: "my-server", server: { type: "node", entry_point: "server/index.js", mcp_config: { command: "node", args: ["${__dirname}/server/index.js", "--dir=${user_config.workspace}"], env: { "API_KEY": "${user_config.api_key}" } } }, user_config: { workspace: { type: "directory", title: "Workspace", required: true }, api_key: { type: "string", title: "API Key", sensitive: true, required: true } } }; const config = await getMcpConfigForManifest({ manifest, extensionPath: "/path/to/extension", systemDirs: { HOME: "/Users/username", DOCUMENTS: "/Users/username/Documents" }, userConfig: { workspace: "/Users/username/projects", api_key: "sk-abc123" }, pathSeparator: "/" }); console.log(config); // { // command: "node", // args: ["/path/to/extension/server/index.js", "--dir=/Users/username/projects"], // env: { "API_KEY": "sk-abc123" } // } } ``` -------------------------------- ### Variable Substitution in MCP Configuration Source: https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md Utilize variables like `${__dirname}` for portable paths in MCP configuration. These are substituted by the implementing desktop app. ```json "mcp_config": { "command": "python", "args": ["${__dirname}/server/main.py"], "env": { "CONFIG_PATH": "${__dirname}/config/settings.json" } } ```