A Model Context Protocol (MCP) server for Dust.tt agents, designed for seamless integration with Claude Desktop via STDIO. Provides robust agent querying, listing, and configuration tools.
The Dust MCP Server provides a standardized interface for interacting with Dust.tt agents through the Model Context Protocol (MCP). It enables seamless integration with Claude Desktop and other MCP-compatible clients, offering features like agent discovery, session management, and message handling.
This section outlines the typical user journey when interacting with the Dust MCP Server and its integrated agents.
- Entry Point: User logs into the Dust platform
- Agent Discovery:
- Views available agents in the Agent Marketplace
- Filters agents by category (e.g., Data Analysis, Content Creation, Research)
- Reviews agent capabilities, ratings, and documentation
- Agent Selection:
- Selects multiple agents based on task requirements
- Creates a new workspace or selects existing one
- Layout Setup:
- Arranges agent panels in a custom layout
- Configures agent-specific settings and permissions
- Context Sharing:
- Enables/disables context sharing between agents
- Sets up data flow between agents
- File Management:
- Uploads files to shared workspace
- Organizes files in project folders
- Sets file access permissions per agent
- Conversation Flow:
- Initiates chat with primary agent
- @mentions other agents to bring them into conversation
- Views inter-agent communication in dedicated threads
- Task Delegation:
- Assigns specific tasks to specialized agents
- Monitors task progress across agents
- Views task dependencies and status
- File Collaboration:
- Shares files with specific agents
- Tracks file access and modifications
- Views version history and agent contributions
- Agent Chaining:
- Creates workflows by chaining agents
- Sets up conditional logic for agent handoffs
- Configures automatic triggers between agents
- Context Management:
- Reviews and edits shared context
- Resolves context conflicts between agents
- Saves context snapshots for future reference
- Report Generation:
- Requests reports from analysis agents
- Customizes report templates and parameters
- Exports reports in multiple formats (PDF, Markdown, HTML)
- Insight Visualization:
- Views interactive dashboards
- Filters and drills down into data visualizations
- Compares outputs from different agents
- Node.js v18 or later
- npm 9.x or later
- A Dust.tt account with API access
- Redis server (for session management)
The Dust MCP Server includes a robust session management system using Redis for persistence. This allows for secure and scalable session handling across multiple instances of the server.
- Redis-based Session Storage: Secure and scalable session storage
- Session Expiration: Automatic cleanup of expired sessions
- Distributed Support: Works in distributed environments
- Session Data: Store arbitrary data with each session
- API Endpoints: RESTful API for session management
-
Environment Variables Add these variables to your
.env
file:# Redis Configuration REDIS_ENABLED=true # Set to false to disable Redis (uses in-memory store) REDIS_URL=redis://localhost:6379 REDIS_PASSWORD= # Leave empty if no password is set REDIS_TLS=false # Set to true for secure connections SESSION_SECRET=your_session_secret_here SESSION_TTL=86400 # 24 hours in seconds
-
Test Connection
You can test your Redis connection with:
node -e "const { createClient } = require('redis'); (async () => { const client = createClient({ url: process.env.REDIS_URL }); await client.connect(); console.log('Redis connected successfully'); await client.quit(); })().catch(console.error);"
-
Disabling Redis for Development
If you want to run the server without Redis for development:
REDIS_ENABLED=false
This will use an in-memory store instead. Note: This is not suitable for production.
-
Skipping Redis Cache Tests
To skip Redis-related tests, set the following environment variable:
SKIP_REDIS_TESTS=true
Or when running tests:
SKIP_REDIS_TESTS=true npm test
Add these environment variables to your .env
file:
# Redis Configuration
REDIS_URL=redis://localhost:6379
REDIS_PASSWORD=your_redis_password
REDIS_TLS=false
SESSION_SECRET=your_session_secret_here
SESSION_TTL=86400 # 24 hours in seconds
POST /api/sessions
Content-Type: application/json
{
"userId": "user123",
"data": {
"role": "admin"
},
"ttl": 86400
}
GET /api/sessions/:sessionId
Authorization: Bearer <session_token>
PATCH /api/sessions/:sessionId
Authorization: Bearer <session_token>
Content-Type: application/json
{
"data": {
"role": "admin",
"preferences": {}
},
"ttl": 86400
}
DELETE /api/sessions/:sessionId
Authorization: Bearer <session_token>
GET /api/sessions/:sessionId/validate
Authorization: Bearer <session_token>
To protect routes with session authentication, use the sessionMiddleware
:
import { sessionMiddleware } from './session/routes/sessionRoutes';
import { redisClient } from './config/redis';
// Apply to specific routes
app.get('/protected-route', sessionMiddleware(redisClient), (req, res) => {
// Access session data
const session = req.session;
res.json({ message: 'Access granted', user: session.userId });
});
// Or apply to all routes
app.use(sessionMiddleware(redisClient));
{
"sessionId": "unique-session-id",
"userId": "user123",
"data": {
// Custom session data
},
"expiresAt": "2025-05-25T12:00:00.000Z",
"createdAt": "2025-05-24T12:00:00.000Z",
"updatedAt": "2025-05-24T12:05:00.000Z"
}
- Secure Your Session Secret: Use a strong, unique secret for session encryption
- Set Appropriate TTL: Balance security and user convenience when setting session TTL
- Validate Sessions: Always validate sessions before processing sensitive operations
- Handle Session Errors: Implement proper error handling for session-related operations
- Monitor Redis: Monitor Redis server health and performance metrics
- Connection Issues: Verify Redis server is running and accessible
- Session Expiry: Check if sessions are expiring too quickly by adjusting TTL
- Memory Usage: Monitor Redis memory usage for large session data
- Logs: Check server logs for session-related errors
The server supports different session storage backends:
- No additional setup required
- Sessions are lost on server restart
- Perfect for local development and testing
# Install Redis (macOS)
brew install redis
# Start Redis server (in a separate terminal)
redis-server
# In your .env file:
SESSION_STORE_TYPE=redis
REDIS_URL=redis://localhost:6379
-
Clone the repository:
git clone https://github.com/Ma3u/dust-mcp-server.git cd dust-mcp-server
-
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env # Edit .env with your configuration LOG_LEVEL=info # Advanced Configuration DUST_AGENT_IDS=agent1,agent2,agent3 MAX_SESSIONS=100 SESSION_TIMEOUT=3600
-
Build the project:
npm run build
-
Start the server:
# For development npm run dev # For production npm start
Variable | Required | Description | Default |
---|---|---|---|
DUST_API_KEY |
Yes | Your Dust.tt API key | - |
DUST_WORKSPACE_ID |
Yes | Your Dust.tt workspace ID | - |
PORT |
No | Port to run the server on | 3000 |
NODE_ENV |
No | Node environment (development /production ) |
development |
LOG_LEVEL |
No | Logging level (error , warn , info , debug ) |
info |
DUST_AGENT_IDS |
No | Comma-separated list of agent IDs to load | - |
MAX_SESSIONS |
No | Maximum number of concurrent sessions | 100 |
SESSION_TIMEOUT |
No | Session timeout in seconds | 3600 (1 hour) |
To use with Claude Desktop:
-
Install MCP Tools globally:
npm install -g @modelcontextprotocol/tools
-
Configure Claude Desktop to use your MCP server:
mcp configs set claude-desktop dust $(which node) $(pwd)/build/dust.js
-
Restart Claude Desktop and start interacting with your Dust agents.
The following MCP tools are available for interacting with Dust agents:
List all available Dust agents in the configured workspace.
Parameters:
includeDetails
(boolean, optional): Whether to include detailed agent information
Example:
{
"includeDetails": true
}
Send a query to a Dust agent.
Parameters:
agentId
(string, required): The ID of the agent to queryquery
(string, required): The query to send to the agentsessionId
(string, optional): Session ID for continuing a conversationcontext
(object, optional): Additional context for the query
Example:
{
"agentId": "agent123",
"query": "What is the weather today?",
"sessionId": "session_456"
}
The Memory Bank system provides persistent storage for agent state and configuration:
- Active Context: Tracks the current state of all active agent sessions
- Decision Log: Records all agent decisions and actions
- Progress Tracking: Monitors task progress and completion status
- System Patterns: Defines reusable interaction patterns
- Product Context: Stores product-specific configurations and data
dust-mcp-server/
├── src/
│ ├── __tests__/ # Test files
│ │ ├── e2e/ # End-to-end tests
│ │ ├── integration/ # Integration tests
│ │ └── unit/ # Unit tests
│ ├── agents/ # Agent implementations
│ ├── api/ # API routes and controllers
│ ├── middleware/ # Express middleware
│ ├── services/ # Business logic services
│ ├── tools/ # MCP tool implementations
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── memory-bank/ # Persistent storage for agent state
│ ├── activeContext.md # Current state of active sessions
│ ├── decisionLog.md # Log of agent decisions
│ ├── progress.md # Task progress tracking
│ ├── systemPatterns.md # Reusable interaction patterns
│ └── productContext.md # Product-specific configurations
├── docs/ # Documentation files
├── tests/ # Additional test resources
├── .env.example # Example environment variables
├── .eslintrc.json # ESLint configuration
├── .gitignore # Git ignore rules
├── jest.config.ts # Jest test configuration
├── package.json # Project dependencies and scripts
├── README.md # This file
└── tsconfig.json # TypeScript configuration
-
Clone the repository and install dependencies:
git clone https://github.com/Ma3u/dust-mcp-server.git cd dust-mcp-server npm install
-
Set up your development environment:
# Install development dependencies npm install -D typescript ts-node ts-jest @types/jest @types/node # Set up pre-commit hooks npm run prepare
-
Configure your environment:
cp .env.example .env # Edit .env with your configuration
-
Start the development server:
npm run dev
The project includes a comprehensive test suite:
# Run all tests
npm test
# Run unit tests
npm run test:unit
# Run integration tests
npm run test:integration
# Run end-to-end tests
npm run test:e2e
# Run tests with coverage
npm run test:coverage
- Unit Tests: Test individual functions and classes in isolation
- Integration Tests: Test interactions between components
- E2E Tests: Test complete user flows
- Mock implementations for external services
- Test database with sample data
- API request/response validation
- Snapshot testing for UI components
The application uses Winston for logging with the following log levels:
error
: Errors that cause the application to failwarn
: Potentially harmful situationsinfo
: General application flow informationdebug
: Detailed debugging informationsilly
: Very detailed debugging information
Add this configuration to your .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Tests",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "test:debug"],
"port": 9229,
"skipFiles": ["<node_internals>/**"]
}
]
}
- TypeScript Errors: Run
npm run lint:fix
to automatically fix common issues - Test Failures: Clear the test database with
npm run test:reset
- Dependency Issues: Delete
node_modules
and runnpm install
API documentation is available in the docs
directory and can be generated using:
npm run docs:generate
The API is documented using OpenAPI (Swagger) and can be viewed at /api-docs
when running in development mode.
- Node.js 18+
- npm 9+
- Docker (optional)
# Install production dependencies
npm ci --only=production
# Build the application
npm run build
# Start the server
NODE_ENV=production npm start
# Build the Docker image
docker build -t dust-mcp-server .
# Run the container
docker run -p 3000:3000 --env-file .env dust-mcp-server
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Dust.tt Documentation
- Model Context Protocol
- Claude Desktop
- Node.js Documentation
- TypeScript Documentation
- Express.js Documentation
- Jest Testing Framework
- Winston Logging
You can run the MCP server in two different modes: HTTP mode or STDIO mode.
To run the server in HTTP mode (for web-based clients):
npm run build
npm start -- --http
The server will listen on the port specified by the PORT
environment variable (default: 3000).
You can interact with the API at http://localhost:3000/api
.
The server supports real-time event streaming via Server-Sent Events (SSE).
- Connect to
http://localhost:3000/events
with an SSE-compatible client to receive server events (e.g., health, agent updates). - Example using
curl
:curl -N http://localhost:3000/events
STDIO mode is used when you want the server to communicate through standard input/output streams rather than HTTP. This is the mode used by Claude Desktop and other MCP clients that communicate via STDIO.
To start the server in STDIO mode:
# Start the server in STDIO mode
node build/dust.js
When running in STDIO mode:
- The server doesn't produce any output to stdout by design, as this channel is reserved for MCP protocol communication
- Any logs or error messages are directed to the logs directory and stderr
- The server is immediately ready to accept MCP client connections
To stop the server, you can use Ctrl+C in the terminal where it's running, or kill the process:
pkill -f "node.*dust-mcp-server"
flowchart TD
subgraph Client["Client Layer"]
A[Claude Desktop] -- "MCP Protocol" --> B[MCP Server]
end
subgraph Server["Dust MCP Server"]
B --> C[Request Handler]
C --> D[Auth Middleware]
D --> E[Windsurf Rules Engine]
E --> F[Tool Router]
subgraph Tools["MCP Tools"]
F --> G[dust_list_agents]
F --> H[dust_agent_query]
F --> I[dust_create_session]
F --> J[dust_end_session]
F --> K[dust_get_session]
F --> L[dust_get_agent]
end
subgraph Services["Core Services"]
M[DustApiService] <--> N[AgentService]
N <--> O[SessionManager]
O <--> P[MemoryBank]
end
end
subgraph External["External Services"]
Q[(Dust AI Platform)]
end
subgraph Memory["Memory Bank"]
R[productContext.md]
S[systemPatterns.md]
T[activeContext.md]
U[decisionLog.md]
V[progress.md]
end
Tools --> Services
Services --> Q
Services --> Memory
%% Styling
classDef client fill:#e1f5fe,stroke:#01579b,color:#01579b
classDef server fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20
classDef external fill:#f3e5f5,stroke:#4a148c,color:#4a148c
classDef memory fill:#fff3e0,stroke:#e65100,color:#e65100
class A,Client client
class B,C,D,E,F,G,H,I,J,K,L,Server server
class Q,External external
class R,S,T,U,V,Memory memory
-
Client Layer:
- Claude Desktop communicates with the MCP Server using the MCP protocol
-
MCP Server:
- Request Handler: Processes incoming MCP requests
- Auth Middleware: Validates API keys and permissions
- Windsurf Rules Engine: Enforces project-specific rules and workflows
- Tool Router: Routes requests to the appropriate MCP tool
- MCP Tools: Individual tools for agent interaction and session management
-
Core Services:
- DustApiService: Handles communication with the Dust AI platform
- AgentService: Manages agent lifecycle and interactions
- SessionManager: Maintains session state and context
- MemoryBank: Manages persistent storage using the memory-bank system
-
Memory Bank:
productContext.md
: Project goals and high-level architecturesystemPatterns.md
: Design patterns and implementation detailsactiveContext.md
: Current status and recent changesdecisionLog.md
: Architectural and implementation decisionsprogress.md
: Task tracking and milestones
-
External Services:
- Dust AI Platform: External service for agent execution and processing
This project uses MCP Tools for testing and integration. Here's how to use them:
- Install MCP Tools globally
npm install -g mcptools
- List available tools in the server
mcp tools node build/dust.js
- Call a specific tool
mcp call dust_list_agents node build/dust.js --params '{"limit": 10}'
mcp call dust_agent_query node build/dust.js --params '{"query": "Give me a summary"}'
- Add the server to your aliases
mcp alias add dust node build/dust.js
mcp alias list
- Configure with Claude Desktop
mcp configs set claude-desktop dust /path/to/node /path/to/dust-mcp-server/build/dust.js
The server provides the following MCP tools for interacting with Dust.tt agents:
List all available agents in the workspace.
Parameters:
query
(string, optional): Filter agents by name or descriptionview
(string, optional): View type for filtering agentslimit
(number, optional): Maximum number of agents to return (default: 10)
Example Request:
mcp call dust_list_agents node build/dust.js --params '{"limit": 10}'
Response:
interface AgentDescriptor {
id: string;
name: string;
description: string;
capabilities: string[];
isActive?: boolean;
lastUsed?: string;
}
Query a Dust agent within a session.
Parameters:
agentId
(string, required): ID of the agent to querymessage
(string, required): The message to send to the agentfiles
(Array<{ name: string; content: string }>, optional): Files to include with the messagesessionId
(string, optional): Existing session ID to continue conversation
Example Request:
{
"agentId": "agent_123",
"message": "What's the weather like?",
"files": [
{
"name": "location.txt",
"content": "San Francisco"
}
]
}
Response:
interface DustMessageResponse {
response: string;
context: Record<string, any>;
}
Create a new session with a Dust agent.
Parameters:
agentId
(string, required): ID of the agent to create a session withcontext
(object, optional): Initial context for the session
Example Request:
mcp call dust_create_session node build/dust.js --params '{
"agentId": "agent_123",
"context": {
"userPreferences": {
"language": "en-US"
}
}
}'
Response:
interface SessionDescriptor {
id: string;
agentId: string;
context: Record<string, any>;
isActive: boolean;
createdAt: string;
lastActivity: string;
}
End an active session.
Parameters:
sessionId
(string, required): ID of the session to end
Example Request:
mcp call dust_end_session node build/dust.js --params '{"sessionId": "sess_123"}'
Get details of a specific session.
Parameters:
sessionId
(string, required): ID of the session to retrieve
Example Request:
mcp call dust_get_session node build/dust.js --params '{"sessionId": "sess_123"}'
Get details of a specific agent.
Parameters:
agentId
(string, required): ID of the agent to retrieve
Example Request:
mcp call dust_get_agent node build/dust.js --params '{"agentId": "agent_123"}'
Response:
interface AgentDescriptor {
id: string;
name: string;
description: string;
capabilities: string[];
isActive: boolean;
createdAt: string;
updatedAt: string;
configuration: Record<string, any>;
}
root/
├── src/ # Main source code
│ ├── services/ # Dust API integration layer
│ └── tools/ # (Deprecated) MCP tool implementations
├── build/ # Compiled JavaScript output
├── logs/ # Application and debug logs
│ └── debug/
├── memory-bank/ # Project context and memory files
├── docs/ # Documentation, images, and moved test/demo scripts
├── .env # Environment configuration (not committed)
├── .env.example # Example environment file
├── package.json # Project manifest
└── README.md # Main documentation (this file)
The test suite includes the following features:
- Mocking: Tests use Jest mocking to isolate the MCP methods from actual API calls
- Test Data: Sample agent configurations and responses are provided in
test/fixtures/
- Parameter Validation: Tests verify that parameters are correctly validated
- Complete Coverage: Tests cover all parameters and response formats
You can run the tests using npm scripts:
# Install dependencies first (if not already installed)
npm install
# Run all tests
npm test
# Run only unit tests
npm run test:unit
# Run only integration tests
npm run test:integration
You can also manually test the MCP functionality using the scripts in docs/
:
# Test MCP tools functionality
node docs/test-mcp-tools.js
# Test STDIO transport
node docs/test-stdio.js
The project includes VS Code debugging configurations for both the server and tests. You can use these configurations to debug the application directly from VS Code.
-
Debug Server (HTTP)
- Launches the server in debug mode with auto-reload
- Attaches to the running Node.js process
- Supports breakpoints and step debugging
-
Debug Tests
- Runs the test suite in debug mode
- Supports breakpoints in test files
- Shows detailed test output
-
Debug Current Test File
- Runs the currently open test file with the debugger attached
- Useful for focusing on a specific test case
- Supports breakpoints in test files and source code
-
Debug All Tests
- Runs all tests in the project with the debugger attached
- Useful for debugging test suites or integration tests
- Supports breakpoints in test files and source code
- Open the project in VS Code
- Set breakpoints in your code by clicking in the gutter next to the line numbers
- Open the Run and Debug view (Ctrl+Shift+D or Cmd+Shift+D)
- Select a debug configuration from the dropdown
- Click the green play button or press F5 to start debugging
Logs are stored in the logs/
directory:
app-YYYY-MM-DD.log
: Application logsserver-YYYY-MM-DD.log
: Server logstest-mcp-YYYY-MM-DD.log
: MCP tools test logs
# Run in development mode with auto-reload
npm run dev
# Build the project
npm run build
For more information about the Dust API, see the official documentation:
MIT