feat(mcp): add context7 MCP and disabled_mcps config support

- Add context7 MCP for library documentation lookup
- Add oh-my-opencode.json config file support for per-project settings
- Support disabled_mcps array to selectively disable built-in MCPs
- Update documentation with Configuration section
This commit is contained in:
YeonGyu-Kim
2025-12-05 02:23:34 +09:00
parent 6495fae979
commit 6220fcddcf
4 changed files with 71 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ English | [한국어](README.ko.md)
- [Oh My OpenCode](#oh-my-opencode)
- [Installation](#installation)
- [Configuration](#configuration)
- [TL;DR](#tldr)
- [Why OpenCode \& Why Oh My OpenCode](#why-opencode--why-oh-my-opencode)
- [Features](#features)
@@ -43,6 +44,20 @@ Add to `~/.config/opencode/opencode.json`:
}
```
## Configuration
You can configure Oh My OpenCode by creating a `oh-my-opencode.json` (or `.oh-my-opencode.json`) file in your project root.
### Disable specific MCPs
If you want to disable specific built-in MCPs, you can use the `disabled_mcps` option.
```json
{
"disabled_mcps": ["context7", "websearch_exa"]
}
```
## TL;DR
- **Model Setup Required**
@@ -120,7 +135,8 @@ I believe in the right tool for the job. For your wallet's sake, use CLIProxyAPI
#### Built-in MCPs
- **websearch_exa**: Exa AI web search. Performs real-time web searches and content scraping. Returns LLM-optimized context from relevant websites.
- **websearch_exa**: Exa AI web search. Performs real-time web searches and can scrape content from specific URLs. Returns LLM-optimized context from relevant websites.
- **context7**: Library documentation lookup. Fetches up-to-date documentation for any library to assist with accurate coding.
### Other Features

View File

@@ -3,7 +3,33 @@ import { builtinAgents } from "./agents"
import { createTodoContinuationEnforcer, createContextWindowMonitorHook, createSessionRecoveryHook } from "./hooks"
import { updateTerminalTitle } from "./features/terminal"
import { builtinTools } from "./tools"
import { builtinMcps } from "./mcp"
import { createBuiltinMcps, type McpName } from "./mcp"
import * as fs from "fs"
import * as path from "path"
interface OhMyOpenCodeConfig {
disabled_mcps?: McpName[]
}
function loadPluginConfig(directory: string): OhMyOpenCodeConfig {
const configPaths = [
path.join(directory, "oh-my-opencode.json"),
path.join(directory, ".oh-my-opencode.json"),
]
for (const configPath of configPaths) {
try {
if (fs.existsSync(configPath)) {
const content = fs.readFileSync(configPath, "utf-8")
return JSON.parse(content) as OhMyOpenCodeConfig
}
} catch {
// Ignore parse errors, use defaults
}
}
return {}
}
const OhMyOpenCodePlugin: Plugin = async (ctx) => {
const todoContinuationEnforcer = createTodoContinuationEnforcer(ctx)
@@ -12,6 +38,8 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
updateTerminalTitle({ sessionId: "main" })
const pluginConfig = loadPluginConfig(ctx.directory)
let mainSessionID: string | undefined
let currentSessionID: string | undefined
let currentSessionTitle: string | undefined
@@ -30,7 +58,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
}
config.mcp = {
...config.mcp,
...builtinMcps,
...createBuiltinMcps(pluginConfig.disabled_mcps),
}
},

5
src/mcp/context7.ts Normal file
View File

@@ -0,0 +1,5 @@
export const context7 = {
type: "remote" as const,
url: "https://mcp.context7.com/mcp",
enabled: true,
}

View File

@@ -1,5 +1,23 @@
import { websearch_exa } from "./websearch-exa"
import { context7 } from "./context7"
export const builtinMcps = {
export type McpName = "websearch_exa" | "context7"
const allBuiltinMcps: Record<McpName, { type: "remote"; url: string; enabled: boolean }> = {
websearch_exa,
context7,
}
export function createBuiltinMcps(disabledMcps: McpName[] = []) {
const mcps: Record<string, { type: "remote"; url: string; enabled: boolean }> = {}
for (const [name, config] of Object.entries(allBuiltinMcps)) {
if (!disabledMcps.includes(name as McpName)) {
mcps[name] = config
}
}
return mcps
}
export const builtinMcps = allBuiltinMcps