Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ The `--client` flag specifies which MCP client you're installing for:
- `goose`
- `zed`
- `warp` (outputs config to copy/paste into Warp's cloud-based settings)
- `codex` (OpenAI's Codex CLI tool)

## License

Expand Down
187 changes: 94 additions & 93 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,95 +1,96 @@
{
"name": "install-mcp",
"version": "1.8.0",
"description": "A CLI tool to install and manage MCP servers.",
"bin": {
"install-mcp": "./bin/run"
},
"directories": {
"lib": "src",
"bin": "bin"
},
"files": [
"dist",
"bin"
],
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/supermemoryai/install-mcp.git"
},
"scripts": {
"build": "tsup-node",
"build:watch": "tsup-node --watch",
"clean": "rimraf dist",
"commit": "cz",
"commitlint": "commitlint --edit",
"compile": "tsc",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"start": "ts-node ./bin/run.ts",
"start:node": "node ./bin/run",
"test": "jest",
"test:watch": "jest --watchAll",
"prepare": "husky",
"release": "semantic-release"
},
"keywords": [
"typescript",
"starter",
"cli",
"mcp"
],
"author": "Dhravya Shah <[email protected]>",
"license": "MIT",
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.3",
"@jest/globals": "^29.7.0",
"@tsconfig/node20": "^20.1.6",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.19.8",
"@types/prompts": "^2.4.9",
"@types/signale": "^1.4.7",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"commitizen": "^4.3.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.2",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-unused-imports": "^3.2.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"rimraf": "^5.0.10",
"semantic-release": "^23.1.1",
"ts-jest": "^29.4.0",
"ts-node": "^10.9.2",
"tsup": "^8.5.0",
"typescript": "^5.8.3"
},
"dependencies": {
"consola": "^3.4.2",
"dotenv": "^16.6.1",
"giget": "^1.2.5",
"js-yaml": "^4.1.0",
"picocolors": "^1.1.1",
"yargs": "^17.7.2"
},
"pnpm": {
"overrides": {
"tmp": "^0.2.4"
}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"packageManager": "[email protected]"
"name": "install-mcp",
"version": "1.9.0",
"description": "A CLI tool to install and manage MCP servers.",
"bin": {
"install-mcp": "./bin/run"
},
"directories": {
"lib": "src",
"bin": "bin"
},
"files": [
"dist",
"bin"
],
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/supermemoryai/install-mcp.git"
},
"scripts": {
"build": "tsup-node",
"build:watch": "tsup-node --watch",
"clean": "rimraf dist",
"commit": "cz",
"commitlint": "commitlint --edit",
"compile": "tsc",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"start": "ts-node ./bin/run.ts",
"start:node": "node ./bin/run",
"test": "jest",
"test:watch": "jest --watchAll",
"prepare": "husky",
"release": "semantic-release"
},
"keywords": [
"typescript",
"starter",
"cli",
"mcp"
],
"author": "Dhravya Shah <[email protected]>",
"license": "MIT",
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.3",
"@jest/globals": "^29.7.0",
"@tsconfig/node20": "^20.1.6",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.19.8",
"@types/prompts": "^2.4.9",
"@types/signale": "^1.4.7",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"commitizen": "^4.3.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.2",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-unused-imports": "^3.2.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"rimraf": "^5.0.10",
"semantic-release": "^23.1.1",
"ts-jest": "^29.4.0",
"ts-node": "^10.9.2",
"tsup": "^8.5.0",
"typescript": "^5.8.3"
},
"dependencies": {
"consola": "^3.4.2",
"dotenv": "^16.6.1",
"giget": "^1.2.5",
"js-yaml": "^4.1.0",
"picocolors": "^1.1.1",
"@iarna/toml": "^2.2.5",
"yargs": "^17.7.2"
},
"pnpm": {
"overrides": {
"tmp": "^0.2.4"
}
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"packageManager": "[email protected]"
}
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions src/client-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ describe('client-config', () => {
'claude-code',
'goose',
'zed',
'codex',
]),
)
})

it('should have at least 13 clients', () => {
expect(clientNames.length).toBeGreaterThanOrEqual(13)
it('should have at least 14 clients', () => {
expect(clientNames.length).toBeGreaterThanOrEqual(14)
})
})

Expand Down Expand Up @@ -171,6 +172,11 @@ describe('client-config', () => {
const result = getConfigPath('vscode')
expect(result.configKey).toBe('mcp.servers')
})

it('should handle codex with nested config key', () => {
const result = getConfigPath('codex')
expect(result.configKey).toBe('mcp_servers')
})
})

describe('readConfig', () => {
Expand Down Expand Up @@ -213,6 +219,13 @@ describe('client-config', () => {
const result = readConfig('vscode')
expect(result).toEqual({ mcp: { servers: {} } })
})

it('should handle codex nested config key', () => {
mockFs.existsSync.mockReturnValue(false)

const result = readConfig('codex')
expect(result).toEqual({ mcp_servers: {} })
})
})

describe('writeConfig', () => {
Expand Down Expand Up @@ -278,6 +291,13 @@ describe('client-config', () => {

expect(mockFs.writeFileSync).toHaveBeenCalled()
})

it('should handle codex nested config key', () => {
const config = { mcp_servers: { server1: { command: 'test' } } }
writeConfig(config, 'codex')

expect(mockFs.writeFileSync).toHaveBeenCalled()
})
})

describe('platform-specific paths', () => {
Expand Down
20 changes: 17 additions & 3 deletions src/client-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import process from 'node:process'
import * as TOML from '@iarna/toml'
import yaml from 'js-yaml'

import { verbose } from './logger'
import { logger, verbose } from './logger'
// import { execFileSync } from "node:child_process"

export interface ClientConfig {
Expand All @@ -17,7 +18,7 @@ interface ClientFileTarget {
path: string
localPath?: string
configKey: string
format?: 'json' | 'yaml' // Add format property for different file types
format?: 'json' | 'yaml' | 'toml' // Add format property for different file types
}
type ClientInstallTarget = ClientFileTarget

Expand Down Expand Up @@ -133,6 +134,12 @@ function getClientPaths(): { [key: string]: ClientInstallTarget } {
: path.join(homeDir, '.config', 'zed', 'settings.json'),
configKey: 'context_servers',
},
codex: {
type: 'file',
path: path.join(process.env.CODEX_HOME || path.join(homeDir, '.codex'), 'config.toml'),
configKey: 'mcp_servers',
format: 'toml',
},
}
}

Expand All @@ -150,6 +157,7 @@ export const clientNames = [
'claude-code',
'goose',
'zed',
'codex',
]

// Helper function to get nested value from an object using dot notation
Expand Down Expand Up @@ -220,6 +228,8 @@ export function readConfig(client: string, local?: boolean): ClientConfig {
let rawConfig: ClientConfig
if (configPath.format === 'yaml') {
rawConfig = (yaml.load(fileContent) as ClientConfig) || {}
} else if (configPath.format === 'toml') {
rawConfig = TOML.parse(fileContent) as ClientConfig
} else {
rawConfig = JSON.parse(fileContent)
}
Expand Down Expand Up @@ -291,6 +301,8 @@ function writeConfigFile(config: ClientConfig, target: ClientFileTarget): void {

if (target.format === 'yaml') {
existingConfig = (yaml.load(fileContent) as ClientConfig) || {}
} else if (target.format === 'toml') {
existingConfig = TOML.parse(fileContent) as ClientConfig
} else {
existingConfig = JSON.parse(fileContent)
}
Expand All @@ -315,11 +327,13 @@ function writeConfigFile(config: ClientConfig, target: ClientFileTarget): void {
lineWidth: -1,
noRefs: true,
})
} else if (target.format === 'toml') {
configContent = TOML.stringify(mergedConfig)
} else {
configContent = JSON.stringify(mergedConfig, null, 2)
}

fs.writeFileSync(target.path, configContent)
console.log(target.path)
logger.info(`Config written to: ${target.path}`)
verbose('Config successfully written')
}
Loading
Loading