Skip to content

Commit 3b65f4c

Browse files
authored
Merge pull request #173 from codelion/codelion-patch-1
Update README.md
2 parents a6aa805 + 1e0d981 commit 3b65f4c

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,126 @@ response = client.chat.completions.create(
219219
> The Anthropic API, llama.cpp-server, and ollama currently do not support sampling multiple responses from a model, which limits the available approaches to the following:
220220
> `cot_reflection`, `leap`, `plansearch`, `rstar`, `rto`, `self_consistency`, `re2`, and `z3`. For models on HuggingFace, you can use the built-in local inference server as it supports multiple responses.
221221
222+
### MCP Plugin
223+
224+
The Model Context Protocol (MCP) plugin enables OptiLLM to connect with MCP servers, bringing external tools, resources, and prompts into the context of language models. This allows for powerful integrations with filesystem access, database queries, API connections, and more.
225+
226+
#### What is MCP?
227+
228+
The [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) is an open protocol standard that allows LLMs to securely access tools and data sources through a standardized interface. MCP servers can provide:
229+
230+
- **Tools**: Callable functions that perform actions (like writing files, querying databases, etc.)
231+
- **Resources**: Data sources for providing context (like file contents)
232+
- **Prompts**: Reusable prompt templates for specific use cases
233+
234+
#### Configuration
235+
236+
##### Setting up MCP Config
237+
238+
1. Create a configuration file at `~/.optillm/mcp_config.json` with the following structure:
239+
240+
```json
241+
{
242+
"mcpServers": {
243+
"filesystem": {
244+
"command": "npx",
245+
"args": [
246+
"-y",
247+
"@modelcontextprotocol/server-filesystem",
248+
"/path/to/allowed/directory1",
249+
"/path/to/allowed/directory2"
250+
],
251+
"env": {}
252+
}
253+
},
254+
"log_level": "INFO"
255+
}
256+
```
257+
258+
Each server entry in `mcpServers` consists of:
259+
260+
- **Server name**: A unique identifier for the server (e.g., "filesystem")
261+
- **command**: The executable to run the server
262+
- **args**: Command-line arguments for the server
263+
- **env**: Environment variables for the server process
264+
- **description** (optional): Description of the server's functionality
265+
266+
#### Available MCP Servers
267+
268+
You can use any of the [official MCP servers](https://modelcontextprotocol.io/examples) or third-party servers. Some popular options include:
269+
270+
- **Filesystem**: `@modelcontextprotocol/server-filesystem` - File operations
271+
- **Git**: `mcp-server-git` - Git repository operations
272+
- **SQLite**: `@modelcontextprotocol/server-sqlite` - SQLite database access
273+
- **Brave Search**: `@modelcontextprotocol/server-brave-search` - Web search capabilities
274+
275+
Example configuration for multiple servers:
276+
277+
```json
278+
{
279+
"mcpServers": {
280+
"filesystem": {
281+
"command": "npx",
282+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/documents"],
283+
"env": {}
284+
},
285+
"search": {
286+
"command": "npx",
287+
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
288+
"env": {
289+
"BRAVE_API_KEY": "your-api-key-here"
290+
}
291+
}
292+
},
293+
"log_level": "INFO"
294+
}
295+
```
296+
297+
#### Using the MCP Plugin
298+
299+
Once configured, the MCP plugin will automatically:
300+
301+
1. Connect to all configured MCP servers
302+
2. Discover available tools, resources, and prompts
303+
3. Make these capabilities available to the language model
304+
4. Handle tool calls and resource requests
305+
306+
The plugin enhances the system prompt with MCP capabilities so the model knows which tools are available. When the model decides to use a tool, the plugin:
307+
308+
1. Executes the tool with the provided arguments
309+
2. Returns the results to the model
310+
3. Allows the model to incorporate the results into its response
311+
312+
#### Example Queries
313+
314+
Here are some examples of queries that will engage MCP tools:
315+
316+
- "List all the Python files in my documents directory" (Filesystem)
317+
- "What are the recent commits in my Git repository?" (Git)
318+
- "Search for the latest information about renewable energy" (Search)
319+
- "Query my database for all users who registered this month" (Database)
320+
321+
#### Troubleshooting
322+
323+
##### Logs
324+
325+
The MCP plugin logs detailed information to:
326+
```
327+
~/.optillm/logs/mcp_plugin.log
328+
```
329+
330+
Check this log file for connection issues, tool execution errors, and other diagnostic information.
331+
332+
##### Common Issues
333+
334+
1. **Command not found**: Make sure the server executable is available in your PATH, or use an absolute path in the configuration.
335+
336+
2. **Connection failed**: Verify the server is properly configured and any required API keys are provided.
337+
338+
3. **Method not found**: Some servers don't implement all MCP capabilities (tools, resources, prompts). Verify which capabilities the server supports.
339+
340+
4. **Access denied**: For filesystem operations, ensure the paths specified in the configuration are accessible to the process.
341+
222342
## Implemented techniques
223343

224344
| Approach | Slug | Description |

0 commit comments

Comments
 (0)