Skip to content

Commit 98b6064

Browse files
authored
Merge pull request #57 from drivecore/docs/add-mcp-documentation
Add documentation for Model Context Protocol (MCP)
2 parents d877127 + e396385 commit 98b6064

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

docs/usage/model-context-protocol.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Model Context Protocol (MCP)
6+
7+
MyCoder includes support for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction), which enables AI assistants to access external context sources and tools during conversations. This page explains how to configure and use MCP with MyCoder.
8+
9+
## What is the Model Context Protocol?
10+
11+
The Model Context Protocol (MCP) is an open standard that allows AI assistants to dynamically access external resources and tools. By integrating MCP, MyCoder can:
12+
13+
- Access documentation, knowledge bases, and other context sources
14+
- Retrieve up-to-date information from external systems
15+
- Use specialized tools and services provided by MCP servers
16+
17+
MCP provides a standardized way for AI assistants to interact with external systems, making it easier to extend their capabilities without modifying the core system.
18+
19+
## How MyCoder Implements MCP
20+
21+
MyCoder uses the official [@modelcontextprotocol/sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk) package to integrate with MCP-compatible servers. The implementation provides:
22+
23+
1. A configuration system to specify MCP servers and default resources
24+
2. A tool that allows the agent to list and retrieve resources from MCP servers
25+
3. Automatic handling of authentication with MCP servers
26+
4. Support for multiple MCP servers simultaneously
27+
5. Robust error handling for connection and resource issues
28+
29+
The MCP implementation in MyCoder is focused primarily on the Resource aspect of MCP, allowing the agent to retrieve context from MCP servers. The protocol itself also defines Tools (similar to POST endpoints) and Prompts (reusable templates), which may be supported in future versions.
30+
31+
## Configuring MCP
32+
33+
To use MCP with MyCoder, you need to configure one or more MCP servers in your `mycoder.config.js` file:
34+
35+
```javascript
36+
// mycoder.config.js
37+
export default {
38+
// Other configuration options...
39+
40+
// MCP configuration
41+
mcp: {
42+
// MCP Servers to connect to
43+
servers: [
44+
{
45+
name: 'company-docs',
46+
url: 'https://mcp.example.com/docs',
47+
// Optional authentication
48+
auth: {
49+
type: 'bearer',
50+
token: process.env.MCP_SERVER_TOKEN,
51+
},
52+
},
53+
],
54+
55+
// Optional: Default context resources to load
56+
defaultResources: ['company-docs://api/reference'],
57+
},
58+
};
59+
```
60+
61+
### Configuration Options
62+
63+
The MCP configuration accepts the following options:
64+
65+
| Option | Description | Type | Default |
66+
|--------|-------------|------|---------|
67+
| `servers` | Array of MCP server configurations | Array | `[]` |
68+
| `defaultResources` | Resources to load automatically | Array of strings | `[]` |
69+
70+
Each server configuration requires:
71+
72+
| Option | Description | Type | Required |
73+
|--------|-------------|------|----------|
74+
| `name` | Unique name for this MCP server | String | Yes |
75+
| `url` | URL of the MCP server | String | Yes |
76+
| `auth` | Authentication configuration | Object | No |
77+
78+
Authentication options:
79+
80+
| Option | Description | Type | Required |
81+
|--------|-------------|------|----------|
82+
| `type` | Authentication type (currently only 'bearer') | String | Yes |
83+
| `token` | Authentication token | String | Yes |
84+
85+
## Using MCP in MyCoder
86+
87+
When MCP is configured, the agent automatically has access to a new `mcp` tool that allows it to:
88+
89+
1. List available resources from configured MCP servers
90+
2. Fetch resources to use as context for its work
91+
92+
### Example: Listing Available Resources
93+
94+
The agent can list all available resources from configured MCP servers:
95+
96+
```
97+
I'll check what resources are available from the MCP servers.
98+
99+
<function_calls>
100+
<invoke name="mcp">
101+
<parameter name="method">listResources

0 commit comments

Comments
 (0)