File size: 14,413 Bytes
0dbc9de | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | ---
title: MCP μλ²
description: λ‘컬 λ° μ격 MCP λꡬλ₯Ό μΆκ°νμΈμ.
---
Model Context Protocol , λλ MCPλ₯Ό μ¬μ©νμ¬ opencodeμ μΈλΆ λꡬλ₯Ό μΆκ°ν μ μμ΅λλ€. opencodeλ λ‘컬 λ° μ격 μλ²λ₯Ό λͺ¨λ μ§μν©λλ€.
μΆκ°λλ©΄ MCP λꡬλ λ΄μ₯ λꡬμ ν¨κ» LLMμ μλμΌλ‘ μ¬μ©ν μ μμ΅λλ€.
---
#### μ£Όμμ¬ν
MCP μλ²λ₯Ό μ¬μ©ν λ 컨ν
μ€νΈμ μΆκ°λ©λλ€. λκ΅¬κ° λ§μΌλ©΄ 컨ν
μ€νΈκ° λΉ λ₯΄κ² μ±μμ§ μ μμ΅λλ€. κ·Έλμ μ°λ¦¬λ λΉμ μ΄ μ¬μ©νλ MCP μλ²μ μ£Όμλ₯Ό κΈ°μΈμ¬μΌ ν©λλ€.
:::tip
MCP μλ²λ κ·νμ 컨ν
μ€νΈμ μΆκ°νλ―λ‘, νμ±νν μ μλ κ²μ μ£Όμν΄μΌ ν©λλ€.
:::
GitHub MCP μλ²μ κ°μ νΉμ MCP μλ²λ λ§μ ν ν°μ μΆκ°νκ³ μ»¨ν
μ€νΈ μ νμ μ½κ² μ΄κ³Ό ν μ μμ΅λλ€.
---
## ꡬμ±
`mcp`μμ MCP μλ²λ₯Ό μ μν μ μμ΅λλ€. κ° MCPλ₯Ό κ³ μ μ΄λ¦μΌλ‘ μΆκ°ν©λλ€. LLMμ ν둬ννΈν λ MCPλ₯Ό μ°Έμ‘°ν μ μμ΅λλ€.
```jsonc title="opencode.jsonc" {6}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"name-of-mcp-server": {
// ...
"enabled": true,
},
"name-of-other-mcp-server": {
// ...
},
},
}
```
`enabled`λ₯Ό `false`λ‘ μ€μ νμ¬ μλ²λ₯Ό λΉνμ±ν ν μ μμ΅λλ€. configμμ μ κ±°νμ§ μκ³ μλ²λ₯Ό μΌμμ μΌλ‘ λΉνμ±ννλ €λ κ²½μ° μ μ©ν©λλ€.
---
### μ격 κΈ°λ³Έκ° μ¬μ μ
μ‘°μ§μ `.well-known/opencode` μλν¬μΈνΈλ₯Ό ν΅ν΄ κΈ°λ³Έ MCP μλ²λ₯Ό μ 곡 ν μ μμ΅λλ€. μ΄ μλ²λ κΈ°λ³Έμ μΌλ‘ λΉνμ±ν λ μ μμΌλ©° μ¬μ©μκ° νμν κ²λ€μ λν΄ μ ν ν μ μμ΅λλ€.
μ‘°μ§μ μ격 μ€μ μμ νΉμ μλ²λ₯Ό νμ±ννλ €λ©΄ `enabled: true`λ‘ λ‘컬 ꡬμ±μ μΆκ°νμμμ€.
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"jira": {
"type": "remote",
"url": "https://jira.example.com/mcp",
"enabled": true
}
}
}
```
λ‘컬 μ€μ κ°μ μ격 κΈ°λ³Έκ°μ 무μν©λλ€. μμΈν λ΄μ©μ [config precedence](/docs/config#precedence-order)λ₯Ό μ°Έμ‘°νμμμ€.
---
## λ‘컬
MCP κ°μ²΄ λ΄μμ `type`λ₯Ό `"local"`λ‘ μ¬μ©νλ λ‘컬 MCP μλ²λ₯Ό μΆκ°νμμμ€.
```jsonc title="opencode.jsonc" {15}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-local-mcp-server": {
"type": "local",
// Or ["bun", "x", "my-mcp-command"]
"command": ["npx", "-y", "my-mcp-command"],
"enabled": true,
"environment": {
"MY_ENV_VAR": "my_env_var_value",
},
},
},
}
```
λͺ
λ Ήμ λ‘컬 MCP μλ²κ° μμλλ λ°©λ²μ
λλ€. λν νκ²½ λ³μ λͺ©λ‘μμ μ λ¬ν μ μμ΅λλ€.
μλ₯Ό λ€μ΄, ν
μ€νΈ [`@modelcontextprotocol/server-everything`](https://www.npmjs.com/package/@modelcontextprotocol/server-everything) MCP μλ²λ₯Ό μΆκ°ν μ μλ λ°©λ²μ
λλ€.
```jsonc title="opencode.jsonc"
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mcp_everything": {
"type": "local",
"command": ["npx", "-y", "@modelcontextprotocol/server-everything"],
},
},
}
```
κ·Έλ¦¬κ³ `use the mcp_everything tool`λ₯Ό λ΄ ν둬ννΈμ μΆκ°ν μ μμ΅λλ€.
```txt "mcp_everything"
use the mcp_everything tool to add the number 3 and 4
```
---
#### μ΅μ
λ‘컬 MCP μλ²λ₯Ό ꡬμ±νλ λͺ¨λ μ΅μ
μ΄ μμ΅λλ€.
| μ΅μ
| νμ
| νμ | μ€λͺ
|
| ------------- | ------- | ---- | ----------------------------------------------------- |
| `type` | λ¬Έμμ΄ | Y | MCP μλ² μ°κ²° μ νμ `"local"`. |
| `command` | Array | Y | MCP μλ²λ₯Ό μ€ννλ λͺ
λ Ήκ³Ό μΈμ. |
| `environment` | κ°μ²΄ | | μλ² μ€νμ μ€μ νλ νκ²½ λ³μ |
| `enabled` | boolean | | μλμμ MCP μλ² μ¬μ© κ°λ₯ |
| `timeout` | number | | MCP μλ²μμ ννν΄μ μν νμμμ κΈ°λ³Έ 5000 (5 μ΄). |
---
## μ격
`type`λ₯Ό `"remote"`λ‘ μ€μ νμ¬ μ격 MCP μλ²λ₯Ό μΆκ°νμμμ€.
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-remote-mcp": {
"type": "remote",
"url": "https://my-mcp-server.com",
"enabled": true,
"headers": {
"Authorization": "Bearer MY_API_KEY"
}
}
}
}
```
`url`λ μ격 MCP μλ²μ URLμ΄λ©° `headers` μ΅μ
μΌλ‘ ν€λ λͺ©λ‘μμ μ λ¬ν μ μμ΅λλ€.
---
#### μ΅μ
| μ΅μ
| νμ
| νμ | μ€λͺ
|
| --------- | ------- | ---- | ----------------------------------------------------------- |
| `type` | λ¬Έμμ΄ | Y | MCP μλ² μ°κ²° μ νμ `"remote"`. |
| `url` | λ¬Έμμ΄ | Y | μ격 MCP μλ²μ URL. |
| `enabled` | boolean | | μλμμ MCP μλ² μ¬μ© κ°λ₯ |
| `headers` | κ°μ²΄ | | ν€λλ¬λ μμ²μΌλ‘ 보λ΄λ립λλ€. |
| `oauth` | κ°μ²΄ | | OAuth μΈμ¦ κ΅¬μ± [OAuth](#oauth) μλμ μΉμ
μ μ°Έμ‘°νμμμ€. |
| `timeout` | number | | MCP μλ²μμ ννν΄μ μν νμμμ κΈ°λ³Έ 5000 (5 μ΄). |
---
## OAuth
opencodeλ μ격 MCP μλ²μ λν OAuth μΈμ¦μ μλμΌλ‘ μ²λ¦¬ν©λλ€. μλ²κ° μΈμ¦μ΄ νμν λ, opencodeλ:
1. 401 μλ΅μ κ²μΆνκ³ OAuth νλ¦μ μμ
2. **Dynamic Client λ±λ‘ (RFC 7591) ** μλ²μμ μ§μλλ κ²½μ°
3. λ―Έλμ μμ²μ λν΄ μμ νκ² λ³΄κ΄ ν ν°
---
## μλ μ€μ
λλΆλΆμ OAuth-enabled MCP μλ²λ₯Ό μν΄, νΉλ³ν ꡬμ±μ νμνμ§ μμ΅λλ€. μ격 μλ²λ₯Ό ꡬμ±:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-oauth-server": {
"type": "remote",
"url": "https://mcp.example.com/mcp"
}
}
}
```
μλ²κ° μΈμ¦μ΄ νμν κ²½μ°, opencodeλ λ¨Όμ μ¬μ©νλ €κ³ ν λ μΈμ¦λ©λλ€. κ·Έλ μ§ μλ€λ©΄, `opencode mcp auth <server-name>`λ₯Ό μ¬μ©νμ¬ [μλμΌλ‘ νΈλ¦¬κ±°](#authenticating)ν μ μμ΅λλ€.
---
### μ¬μ λ±λ‘
MCP μλ² κ³΅κΈμμ ν΄λΌμ΄μΈνΈ μ격μ΄μλ κ²½μ°, κ΅¬μ± ν μ μμ΅λλ€.
```json title="opencode.json" {7-11}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-oauth-server": {
"type": "remote",
"url": "https://mcp.example.com/mcp",
"oauth": {
"clientId": "{env:MY_MCP_CLIENT_ID}",
"clientSecret": "{env:MY_MCP_CLIENT_SECRET}",
"scope": "tools:read tools:execute"
}
}
}
}
```
---
### μΈμ¦
μΈμ¦ λλ μ격 μ¦λͺ
μ μλμΌλ‘ νΈλ¦¬κ±° ν μ μμ΅λλ€.
νΉμ MCP μλ²μ μΈμ¦:
```bash
opencode mcp auth my-oauth-server
```
λͺ¨λ MCP μλ²λ₯Ό λμ΄νκ³ auth μν:
```bash
opencode mcp list
```
μ μ₯λ μ격 μ κ±°:
```bash
opencode mcp logout my-oauth-server
```
`mcp auth` λͺ
λ Ήμ μ¬μ©μμ λΈλΌμ°μ λ₯Ό μ½λλ€. `~/.local/share/opencode/mcp-auth.json`μμ ν ν°μ μμ νκ² μ μ₯ν©λλ€.
---
#### OAuth λΉνμ±ν
μλ²μ μλ OAuthλ₯Ό λΉνμ±ννλ €λ κ²½μ° (μλ₯Ό λ€μ΄, λμ API ν€λ₯Ό μ¬μ©νλ μλ²), `oauth`λ₯Ό `false`λ‘ μ€μ :
```json title="opencode.json" {7}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-api-key-server": {
"type": "remote",
"url": "https://mcp.example.com/mcp",
"oauth": false,
"headers": {
"Authorization": "Bearer {env:MY_API_KEY}"
}
}
}
}
```
---
#### OAuth μ΅μ
| μ΅μ
| μ ν | μ€λͺ
|
| -------------- | ------------- | --------------------------------------------------------------------------- |
| `oauth` | κ°μ²΄ \| false | OAuth config object, λλ `false`λ₯Ό λΉνμ±ννλ OAuth μλκ²μΆ. Β· |
| `clientId` | λ¬Έμμ΄ | OAuth ν΄λΌμ΄μΈνΈ ID. μ 곡λμ§ μμ κ²½μ°, λμ ν΄λΌμ΄μΈνΈ λ±λ‘ μλλ©λλ€. Β· |
| `clientSecret` | String | OAuth ν΄λΌμ΄μΈνΈ λΉλ°, νκ°μ μλ²κ° νμν κ²½μ°. |
| `scope` | String | OAuth λ²μλ μΈμ¦ μ€μ
λλ€. |
###### λλ²κΉ
μ격 MCP μλ²κ° μΈμ¦μ μ€ν¨νλ©΄ λ€μκ³Ό κ°μ λ¬Έμ λ₯Ό μ§λ¨ ν μ μμ΅λλ€.
```bash
# View auth status for all OAuth-capable servers
opencode mcp auth list
# Debug connection and OAuth flow for a specific server
opencode mcp debug my-oauth-server
```
`mcp debug` λͺ
λ Ήμ νμ¬ auth μνλ₯Ό λ³΄μ¬ μ£Όλ©° HTTP μ°κ²°μ ν
μ€νΈνκ³ OAuth λ°κ²¬ νλ¦μ μλν©λλ€.
---
## κ΄λ¦¬
MCPλ opencodeμ λκ΅¬λ‘ μ¬μ©ν μ μμΌλ©° λ΄μ₯ λꡬμ ν¨κ» μ¬μ©ν μ μμ΅λλ€. λ€λ₯Έ λꡬμ κ°μ΄ opencode configλ₯Ό ν΅ν΄ κ΄λ¦¬ν μ μμ΅λλ€.
---
## μ μ
μ΄λ μ μμ μΌλ‘ νμ±ννκ±°λ λΉνμ±νν μ μμμ μλ―Έν©λλ€.
```json title="opencode.json" {14}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-mcp-foo": {
"type": "local",
"command": ["bun", "x", "my-mcp-command-foo"]
},
"my-mcp-bar": {
"type": "local",
"command": ["bun", "x", "my-mcp-command-bar"]
}
},
"tools": {
"my-mcp-foo": false
}
}
```
λν glob ν¨ν΄μ μ¬μ©νμ¬ μΌμΉνλ λͺ¨λ MCPλ₯Ό λΉνμ±νν μ μμ΅λλ€.
```json title="opencode.json" {14}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-mcp-foo": {
"type": "local",
"command": ["bun", "x", "my-mcp-command-foo"]
},
"my-mcp-bar": {
"type": "local",
"command": ["bun", "x", "my-mcp-command-bar"]
}
},
"tools": {
"my-mcp*": false
}
}
```
μ¬κΈ°μ μ°λ¦¬λ λͺ¨λ MCPλ₯Ό λΉνμ±ννλ glob ν¨ν΄ `my-mcp*`λ₯Ό μ¬μ©ν©λλ€.
---
## μμ΄μ νΈλ³
λ§μ MCP μλ²κ° μλ€λ©΄ μ μμ μΌλ‘λ λΉνμ±ννκ³ μμ΄μ νΈλ³λ‘λ§ νμ±νν μ μμ΅λλ€. μ΄ μμ
μ μν:
1. κΈλ‘λ² λκ΅¬λ‘ μ¬μ© κ°λ₯.
2. [agent config](/docs/agents#tools)μμ MCP μλ²λ₯Ό λκ΅¬λ‘ μ¬μ©ν μ μμ΅λλ€.
```json title="opencode.json" {11, 14-18}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"my-mcp": {
"type": "local",
"command": ["bun", "x", "my-mcp-command"],
"enabled": true
}
},
"tools": {
"my-mcp*": false
},
"agent": {
"my-agent": {
"tools": {
"my-mcp*": true
}
}
}
}
```
---
### Glob ν¨ν΄
glob ν¨ν΄μ κ°λ¨ν regex globbing ν¨ν΄μ μ¬μ©ν©λλ€ :
- `*`λ μ΄λ€ νΉμ± (μλ₯Όλ€λ©΄, `"my-mcp*"` κ²½κΈ° `my-mcp_search`, `my-mcp_list`, λ±)μ 0κ° μ΄μ μΌμΉν©λλ€.
- `?`λ μ νν νλμ λ¬Έμ μΌμΉ
- λ€λ₯Έ λͺ¨λ λ¬Έμ μΌμΉ λ§ κ·Έλλ‘
:::note
MCP μλ² λꡬλ μλ² μ΄λ¦μΌλ‘ prefixλ‘ λ±λ‘λλ―λ‘ μλ²μ λͺ¨λ λꡬλ₯Ό κ°λ¨νκ² μ¬μ©ν μ μμ΅λλ€.
```
"mymcpservername_*": false
```
:::
---
## μμ
λ€μμ μΌλ°μ μΈ MCP μλ²μ μμ
λλ€. λ€λ₯Έ μλ²μ λ¬Έμλ₯Ό μμ±νλ €λ©΄ PRμ μ μΆν μ μμ΅λλ€.
---
#### Sentry
[Sentry MCP μλ²](https://mcp.sentry.dev)λ₯Ό μΆκ°νμ¬ Sentry νλ‘μ νΈμ λ¬Έμ μ μνΈ μμ©ν©λλ€.
```json title="opencode.json" {4-8}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sentry": {
"type": "remote",
"url": "https://mcp.sentry.dev/mcp",
"oauth": {}
}
}
}
```
ꡬμ±μ μΆκ° ν ν, Sentryλ‘ μΈμ¦:
```bash
opencode mcp auth sentry
```
λΈλΌμ°μ μ°½μ μ΄μ΄ OAuth νλ¦μ μλ£νκ³ opencodeλ₯Ό Sentry κ³μ μ μ°κ²°νμμμ€.
μΌλ¨ μΈμ¦λλ©΄, λΉμ μ 쿼리 λ¬Έμ , νλ‘μ νΈ, μ€λ₯ λ°μ΄ν°μ λν νλ¦°νΈ λꡬλ₯Ό μ¬μ©ν μ μμ΅λλ€.
```txt "use sentry"
Show me the latest unresolved issues in my project. use sentry
```
---
### Context7
[Context7 MCP μλ²](https://github.com/upstash/context7)μ μΆκ°νμ¬ λ¬Έμλ₯Ό κ²μν©λλ€.
```json title="opencode.json" {4-7}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp"
}
}
}
```
λ¬΄λ£ κ³μ μΌλ‘ κ°μ
ν κ²½μ° API ν€λ₯Ό μ¬μ©νμ¬ λ λμ μλ μ νμ μ»μ μ μμ΅λλ€.
```json title="opencode.json" {7-9}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
}
}
}
}
```
μ¬κΈ°μμ μ°λ¦¬λ λΉμ μ΄ `CONTEXT7_API_KEY` νκ²½ λ³μ μΈνΈκ° μλ€λ κ²μ assumingμ
λλ€.
Context7 MCP μλ²λ₯Ό μ¬μ©νμ¬ `use context7`λ₯Ό μ μνκ² μΆκ°νμμμ€.
```txt "use context7"
Configure a Cloudflare Worker script to cache JSON API responses for five minutes. use context7
```
λμμΌλ‘, λΉμ μμ΄ κ°μ λκ°λ₯Ό μΆκ° ν μ μμ΅λλ€ [AGENTS.md](/docs/rules/).
```md title="AGENTS.md"
When you need to search docs, use `context7` tools.
```
---
## Grep by Vercel
[Grep by Vercel](https://grep.app) MCP μλ²λ₯Ό μΆκ°νμ¬ GitHubμμ μ½λ μ€λν«μ κ²μν©λλ€.
```json title="opencode.json" {4-7}
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"gh_grep": {
"type": "remote",
"url": "https://mcp.grep.app"
}
}
}
```
MCP μλ² `gh_grep`λΌλ μ΄λ¦μΌλ‘, `use the gh_grep tool`λ₯Ό μΆκ°ν μ μμ΅λλ€.
```txt "use the gh_grep tool"
What's the right way to set a custom domain in an SST Astro component? use the gh_grep tool
```
λμμΌλ‘, λΉμ μμ΄ κ°μ λκ°λ₯Ό μΆκ° ν μ μμ΅λλ€ [AGENTS.md](/docs/rules/).
```md title="AGENTS.md"
If you are unsure how to do something, use `gh_grep` to search code examples from GitHub.
```
|