---
title: "Configuration"
description: "Configure your agents and LLM settings"
icon: "cog"
---

import { CodeSandbox } from '/snippets/codesandbox.jsx'

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.

<Info>
**Looking for client configuration?** This guide covers agent-specific configuration. For MCP client and server connection setup, see the [Client Configuration](/typescript/client/client-configuration) guide.
</Info>

## Basic Configuration

Create an agent with minimal configuration:

```typescript
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
})
```

<CodeSandbox title="Edit mcp-use-get-started-agent" id="sweet-drake-m76ys6"/>

## Agent Parameters

When creating an MCPAgent, you can configure several parameters to customize its behavior:

<CodeGroup>
```typescript TypeScript
// 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
})
```
</CodeGroup>

### 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)

## Tool Access Control

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:

<CodeGroup>
```typescript TypeScript
...
// mcp sevrers with filesystem, network, shell, and database

const agent = new MCPAgent({
  llm,
  client,
  disallowedTools: ['file_system', 'network', 'shell', 'database']
})

...

```
</CodeGroup>

You can also manage tool restrictions dynamically:

<CodeGroup>
```typescript TypeScript
// 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}`)
```
</CodeGroup>


## 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`.

```typescript
// 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](./server-manager) guide.

## Memory

MCPAgent supports conversation memory to maintain context across interactions:

```typescript
// 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](/typescript/agent/memory-management) guide.

## System Prompt

You can customize the agent's behavior through system prompts:

```typescript
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

- [Memory Management](/typescript/agent/memory-management)
- [Server Manager](/typescript/agent/server-manager)