mcpboss
v1.2.1
Published
Javascript/Typescript SDK for MCP Boss
Readme
Install
npm install mcpbossQuick Start SDK
import { McpBoss } from 'mcpboss';
const client = new McpBoss();
// Agents
await client.query('Current weather?');
await client.query('Weather tomorrow?', {
limitTools: ['getWeather'],
});
// List MCP Servers
await client.api.getMcpServers();Quick Start CLI
npm i -g mcpboss
mcpboss config login # login
mcpboss hosted ls # list hosted toolsPackage & Upload Hosted Tool
mkdir pkg
echo 'export const schema = {}' > pkg/index.js
mcpboss hosted deploy pgkConfiguration
This is the default configuration lookup strategy:
- Passed options (only SDK)
- Environment variables
MCPBOSS_ORG_IDandMCPBOSS_API_KEY - Configurations from
~/.mcpboss.configin the following orderMCPBOSS_ORG_ID- The default organization
SDK
Authentication can be controlled in the constructor by providing a custom ConfigLoader:
const client = new McpBoss({ configLoader: ConfigLoader });The configLoader must follow this shape:
{
getConfig(): { baseUrl: string; token: () => Promise<string> } | null;
}Agent Usage
Basic Query
const response = await client.query('Hello, how are you?');
if (response.type === 'success') {
console.log(response.text);
console.log(response.fullOutput); // Complete API response
} else {
console.error('Error:', response.text);
}Advanced Query Options
const response = await client.query('Search for recent news about AI', {
agentId: 'specific-agent-id', // Use a specific agent
modelId: 'gpt-4', // Use a specific model
llmApiKeyId: 'my-openai-key', // Use a specific API key
limitMcpServers: ['news-server'], // Limit to specific MCP servers
limitTools: ['brave_news_search'], // Limit to specific tools
dontAutoCreateAgent: false, // Prevent auto-creation of agents
timeoutInMilliseconds: 300e3, // Wait maximum 5 minutes for LLM generation
});Agent Management
The SDK automatically handles agent selection and creation with intelligent fallback logic:
- Exact Match: If
agentIdis provided, uses that specific agent - Model + API Key: Finds agent matching both
modelIdandllmApiKeyId - Model Only: Finds agent matching
modelId - API Key Only: Finds agent matching
llmApiKeyId - Auto-Create: Creates a new agent if none match (unless
dontAutoCreateAgentis true) - Fallback: Uses the first available agent if no criteria specified
When auto-creating agents, the SDK will:
- Prefer the specified
modelIdif available - Fall back to GPT-5 if available
- Use the first available model as a last resort
- Apply the specified
llmApiKeyIdor use the default
Debugging
The SDK uses the debug package for logging. Enable debug output with:
DEBUG=mcpboss node your-script.jsLicense
MIT License - see LICENSE file for details.
Contributing
We welcome contributions!
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
