feat(mcp): register ast-grep as built-in MCP

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-18 21:19:24 +09:00
parent 499aff011a
commit ef09880e26
9 changed files with 273 additions and 22 deletions
+18 -12
View File
@@ -4,12 +4,19 @@ afterEach(() => {
mock.restore()
})
function mockLocalMcps(): void {
mock.module("../lsp", () => ({
createLspMcpConfig: () => ({ type: "local", command: ["node", "dist/cli.js", "mcp"], enabled: true }),
}))
mock.module("../ast-grep", () => ({
createAstGrepMcpConfig: () => ({ type: "local", command: ["node", "ast-grep-mcp", "mcp"], enabled: true }),
}))
}
describe("createBuiltinMcps", () => {
test("should return all MCPs when disabled_mcps is empty", () => {
// given
mock.module("../lsp", () => ({
createLspMcpConfig: () => ({ type: "local", command: ["node", "dist/cli.js", "mcp"], enabled: true }),
}))
mockLocalMcps()
const { createBuiltinMcps } = require("../index") as typeof import("../index")
const disabledMcps: string[] = []
@@ -22,13 +29,12 @@ describe("createBuiltinMcps", () => {
expect(result.context7).toBeDefined()
expect(result.grep_app).toBeDefined()
expect(result.lsp).toBeDefined()
expect(result.ast_grep).toBeDefined()
})
test("should filter out disabled MCPs", () => {
// given
mock.module("../lsp", () => ({
createLspMcpConfig: () => ({ type: "local", command: ["node", "dist/cli.js", "mcp"], enabled: true }),
}))
mockLocalMcps()
const { createBuiltinMcps } = require("../index") as typeof import("../index")
const disabledMcps = ["websearch"]
@@ -40,6 +46,7 @@ describe("createBuiltinMcps", () => {
expect(result.context7).toBeDefined()
expect(result.grep_app).toBeDefined()
expect(result.lsp).toBeDefined()
expect(result.ast_grep).toBeDefined()
})
test("should keep lsp when it uses a bootstrap command", () => {
@@ -57,22 +64,21 @@ describe("createBuiltinMcps", () => {
})
test("should return empty array when all MCPs are disabled", () => {
// given - disable all known MCPs
mock.module("../lsp", () => ({
createLspMcpConfig: () => ({ type: "local", command: ["node", "dist/cli.js", "mcp"], enabled: true }),
}))
// given
mockLocalMcps()
const { createBuiltinMcps } = require("../index") as typeof import("../index")
const disabledMcps = ["websearch", "context7", "grep_app", "lsp"]
const disabledMcps = ["websearch", "context7", "grep_app", "lsp", "ast_grep"]
// when
const result = createBuiltinMcps(disabledMcps)
// then - may still have MCPs we didn't list
// then
const remainingMcpNames = Object.keys(result)
expect(remainingMcpNames).not.toContain("websearch")
expect(remainingMcpNames).not.toContain("context7")
expect(remainingMcpNames).not.toContain("grep_app")
expect(remainingMcpNames).not.toContain("lsp")
expect(remainingMcpNames).not.toContain("ast_grep")
expect(remainingMcpNames).toEqual([])
})
})