@mcplex-js/mcplex
v0.1.0
Published
MCPlex core library for MCP tools and widgets
Maintainers
Readme
@mcplex-js/mcplex
MCPlex core library for MCP tools and widgets.
Installation
npm install @mcplex-js/mcplexUsage
import { MCPlexServer } from '@mcplex-js/mcplex';
// Initialize MCPlex
const mcplex = new MCPlexServer({
fastmcpOpts: {
// FastMCP server options - see FastMCP documentation
name: 'my-mcplex-server',
version: '1.0.0',
// ... other FastMCP options
},
importMapUrl: 'https://example.com/importmap.json',
includePatterns: ['**'], // optional
refreshImportMapIntervalMs: 5000 // optional
});
// Start the server
await mcplex.start();Configuration Options
The MCPlexServer constructor accepts an options object with the following properties:
fastmcpOpts (required)
Type: ServerOptions<T>
FastMCP server configuration options. This includes all the standard FastMCP server options such as:
name- Server nameversion- Server versionlogger- Custom logger instance- Authentication and session options
- Other FastMCP-specific configuration
See the FastMCP documentation for complete details on available options.
importMapUrl (required)
Type: string
URL to the import map JSON file that defines the modules and their locations. The import map should follow the standard import map format with an imports object mapping module names to URLs.
Example import map:
{
"imports": {
"@my-org/widget-library": "https://cdn.example.com/widgets/v1/index.js",
"chart-tools": "https://unpkg.com/[email protected]/dist/index.js"
}
}includePatterns (optional)
Type: string[]
Default: ['**']
Array of glob patterns to match against module names in the import map. Only modules matching these patterns will be loaded and processed. Uses micromatch for pattern matching.
Examples:
['**']- Include all modules (default)['@my-org/**']- Include only modules under @my-org scope['widget-*', 'tool-*']- Include modules starting with "widget-" or "tool-"
refreshImportMapIntervalMs (optional)
Type: number
Default: 5000 (5 seconds)
Interval in milliseconds for automatically refreshing the import map and reloading tools/resources. Set to 0 or negative value to disable automatic refresh.
Methods
start(options?)
Starts the MCPlex server, loads the import map, and registers all tools and resources.
stop()
Stops the MCPlex server and cleans up resources including the automatic refresh interval.
License
ISC
