Skip to content
Merged
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
6,898 changes: 3,043 additions & 3,855 deletions .pnp.cjs

Large diffs are not rendered by default.

1,223 changes: 339 additions & 884 deletions .pnp.loader.mjs

Large diffs are not rendered by default.

Binary file modified .yarn/install-state.gz
Binary file not shown.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A TypeScript-based CLI tool that allows models to interact with various Model Co

- πŸš€ TypeScript-based CLI with full type safety
- πŸ“¦ Distributed on npm as `clicp`
- πŸ”§ Built-in support for popular MCP servers (filesystem, git)
- πŸ”§ Built-in support for popular MCP servers (filesystem, git, github, postgres)
- 🎨 Beautiful colored output with chalk
- βœ… Comprehensive testing with Jest
- πŸ” Code formatting with Prettier
Expand All @@ -32,6 +32,8 @@ clicp list
```bash
clicp filesystem list
clicp git list
clicp github list
clicp postgres list
```

## Available MCP Servers
Expand All @@ -48,6 +50,22 @@ clicp git list
- **git_log**: Get git commit history
- **git_diff**: Get git diff for changes

### GitHub Server

- **create_or_update_file**: Create or update a single file in a repository
- **get_file_contents**: Get contents of a file or directory
- **create_issue**: Create a new issue
- **create_pull_request**: Create a new pull request
- **search_repositories**: Search for GitHub repositories

*Note: Requires `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable*

### PostgreSQL Server

- **query**: Execute read-only SQL queries against the connected database

*Note: Requires `POSTGRES_CONNECTION_STRING` environment variable (defaults to `postgresql://localhost/postgres`)*

## Development

### Prerequisites
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"author": "Codegen",
"license": "MIT",
"dependencies": {
"@modelcontextprotocol/server-github": "^2025.4.8",
"@modelcontextprotocol/server-postgres": "^0.6.2",
"@types/inquirer": "^9.0.7",
"chalk": "^4.1.2",
"commander": "^11.1.0",
Expand Down
20 changes: 19 additions & 1 deletion src/__tests__/mcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ describe('MCPService', () => {
describe('getServers', () => {
it('should return default servers', () => {
const servers = mcpService.getServers();
expect(servers).toHaveLength(2);
expect(servers).toHaveLength(4);
expect(servers.map((s) => s.name)).toContain('filesystem');
expect(servers.map((s) => s.name)).toContain('git');
expect(servers.map((s) => s.name)).toContain('github');
expect(servers.map((s) => s.name)).toContain('postgres');
});
});

Expand Down Expand Up @@ -47,6 +49,22 @@ describe('MCPService', () => {
expect(tools.map((t) => t.name)).toContain('git_diff');
});

it('should return tools for github server', async () => {
const tools = await mcpService.getToolsForServer('github');
expect(tools).toHaveLength(5);
expect(tools.map((t) => t.name)).toContain('create_or_update_file');
expect(tools.map((t) => t.name)).toContain('get_file_contents');
expect(tools.map((t) => t.name)).toContain('create_issue');
expect(tools.map((t) => t.name)).toContain('create_pull_request');
expect(tools.map((t) => t.name)).toContain('search_repositories');
});

it('should return tools for postgres server', async () => {
const tools = await mcpService.getToolsForServer('postgres');
expect(tools).toHaveLength(1);
expect(tools.map((t) => t.name)).toContain('query');
});

it('should throw error for non-existent server', async () => {
await expect(mcpService.getToolsForServer('nonexistent')).rejects.toThrow(
"Server 'nonexistent' not found"
Expand Down
123 changes: 123 additions & 0 deletions src/services/mcpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ export class MCPService {
args: ['@modelcontextprotocol/server-git'],
status: 'active',
});

// GitHub MCP server
this.servers.set('github', {
name: 'github',
description: 'GitHub API operations for repository management, file operations, and search',
command: 'npx',
args: ['@modelcontextprotocol/server-github'],
env: {
GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_PERSONAL_ACCESS_TOKEN || '',
},
status: 'active',
});

// PostgreSQL MCP server
this.servers.set('postgres', {
name: 'postgres',
description: 'PostgreSQL database operations and schema inspection',
command: 'npx',
args: ['@modelcontextprotocol/server-postgres', process.env.POSTGRES_CONNECTION_STRING || 'postgresql://localhost/postgres'],
status: 'active',
});
}

/**
Expand Down Expand Up @@ -157,6 +178,108 @@ export class MCPService {
},
];

case 'github':
return [
{
name: 'create_or_update_file',
description: 'Create or update a single file in a repository',
inputSchema: {
type: 'object',
properties: {
owner: { type: 'string', description: 'Repository owner (username or organization)' },
repo: { type: 'string', description: 'Repository name' },
path: { type: 'string', description: 'Path where to create/update the file' },
content: { type: 'string', description: 'Content of the file' },
message: { type: 'string', description: 'Commit message' },
branch: { type: 'string', description: 'Branch to create/update the file in' },
sha: { type: 'string', description: 'SHA of file being replaced (for updates)' },
},
required: ['owner', 'repo', 'path', 'content', 'message', 'branch'],
},
server: serverName,
},
{
name: 'get_file_contents',
description: 'Get contents of a file or directory',
inputSchema: {
type: 'object',
properties: {
owner: { type: 'string', description: 'Repository owner' },
repo: { type: 'string', description: 'Repository name' },
path: { type: 'string', description: 'Path to file/directory' },
branch: { type: 'string', description: 'Branch to get contents from' },
},
required: ['owner', 'repo', 'path'],
},
server: serverName,
},
{
name: 'create_issue',
description: 'Create a new issue',
inputSchema: {
type: 'object',
properties: {
owner: { type: 'string', description: 'Repository owner' },
repo: { type: 'string', description: 'Repository name' },
title: { type: 'string', description: 'Issue title' },
body: { type: 'string', description: 'Issue description' },
assignees: { type: 'array', items: { type: 'string' }, description: 'Usernames to assign' },
labels: { type: 'array', items: { type: 'string' }, description: 'Labels to add' },
},
required: ['owner', 'repo', 'title'],
},
server: serverName,
},
{
name: 'create_pull_request',
description: 'Create a new pull request',
inputSchema: {
type: 'object',
properties: {
owner: { type: 'string', description: 'Repository owner' },
repo: { type: 'string', description: 'Repository name' },
title: { type: 'string', description: 'PR title' },
body: { type: 'string', description: 'PR description' },
head: { type: 'string', description: 'Branch containing changes' },
base: { type: 'string', description: 'Branch to merge into' },
draft: { type: 'boolean', description: 'Create as draft PR' },
},
required: ['owner', 'repo', 'title', 'head', 'base'],
},
server: serverName,
},
{
name: 'search_repositories',
description: 'Search for GitHub repositories',
inputSchema: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search query' },
page: { type: 'number', description: 'Page number for pagination' },
perPage: { type: 'number', description: 'Results per page (max 100)' },
},
required: ['query'],
},
server: serverName,
},
];

case 'postgres':
return [
{
name: 'query',
description: 'Execute read-only SQL queries against the connected database',
inputSchema: {
type: 'object',
properties: {
sql: { type: 'string', description: 'The SQL query to execute' },
},
required: ['sql'],
},
server: serverName,
},
];

default:
return [];
}
Expand Down
Loading
Loading