Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
Configure your MCPAgent to customize behavior, set LLM parameters, enable features, and optimize for your specific use case. This guide covers all configuration options available when creating and running agents.
Looking for client configuration? This guide covers agent-specific configuration. For MCP client and server connection setup, see the Client Configuration guide.
Basic Configuration
Create an agent with minimal configuration:
import { MCPAgent, MCPClient } from 'mcp-use'
import { ChatOpenAI } from '@langchain/openai'
const client = new MCPClient({
mcpServers: {
filesystem: {
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-filesystem', './']
}
}
})
await client.createAllSessions()
const llm = new ChatOpenAI({ model: "gpt-5.5" })
const agent = new MCPAgent({
llm,
client
})
Agent Parameters
When creating an MCPAgent, you can configure several parameters to customize its behavior:
// Advanced configuration
const advancedAgent = new MCPAgent({
llm: new ChatOpenAI({ model: "gpt-5.5", temperature: 0.7 }),
client: new MCPClient(config),
maxSteps: 30,
autoInitialize: true,
memoryEnabled: true,
systemPrompt: 'Custom instructions for the agent',
additionalInstructions: 'Additional guidelines for specific tasks',
disallowedTools: ['file_system', 'network', 'shell'] // Restrict potentially dangerous tools
})
Available Parameters
llm: Any LangChain-compatible language model (required)
client: The MCPClient instance (optional if connectors are provided)
connectors: List of connectors if not using client (optional)
maxSteps: Maximum number of steps the agent can take (default: 5)
autoInitialize: Whether to initialize automatically (default: false)
memoryEnabled: Whether to enable memory (default: true)
systemPrompt: Custom system prompt (optional)
systemPromptTemplate: Custom system prompt template (optional)
additionalInstructions: Additional instructions for the agent (optional)
disallowedTools: List of tool names that should not be available to the agent (optional)
useServerManager: Enable dynamic server selection (default: false)
You can restrict which tools are available to the agent for security or to limit its capabilities. Here’s a complete example showing how to set up an agent with restricted tool access:
...
// mcp sevrers with filesystem, network, shell, and database
const agent = new MCPAgent({
llm,
client,
disallowedTools: ['file_system', 'network', 'shell', 'database']
})
...
You can also manage tool restrictions dynamically:
// Update restrictions after initialization
agent.setDisallowedTools(['file_system', 'network', 'shell', 'database'])
await agent.initialize() // Reinitialize to apply changes
// Check current restrictions
const restrictedTools = agent.getDisallowedTools()
console.log(`Restricted tools: ${restrictedTools}`)
Server Manager
The Server Manager is an agent-level feature that enables dynamic server selection for improved performance with multi-server setups.
To improve efficiency and potentially reduce agent confusion when many tools are available, you can enable the Server Manager by setting useServerManager: true when creating the MCPAgent.
// Enable server manager for automatic server selection
const agent = new MCPAgent({
llm,
client,
useServerManager: true // Enable dynamic server selection
})
For more details on server manager implementation, see the Server Manager guide.
Memory
MCPAgent supports conversation memory to maintain context across interactions:
// Enable memory (default)
const agent = new MCPAgent({
llm,
client,
memoryEnabled: true
})
// Disable memory for stateless interactions
const statelessAgent = new MCPAgent({
llm,
client,
memoryEnabled: false
})
For more details on memory management, see the Memory Management guide.
System Prompt
You can customize the agent’s behavior through system prompts:
const customPrompt = `
You are a helpful assistant specialized in data analysis.
Always provide detailed explanations for your reasoning.
When working with data, prioritize accuracy over speed.
`
const agent = new MCPAgent({
llm,
client,
systemPrompt: customPrompt
})
Next Steps