octocode-mcp 7.0.2 → 7.0.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,88 +1,49 @@
1
- <div align="center">
2
- <img src="https://github.com/bgauryy/octocode-mcp/raw/main/packages/octocode-mcp/assets/logo_white.png" width="400px" alt="Octocode Logo">
3
-
4
- **Transform Any AI Assistant Into a Code Research Expert**
5
-
6
- The missing piece for AI agents that need quality code context. Search millions of repositories, analyze real implementations, and discover proven patterns — all through a secure, token-efficient MCP server.
7
-
8
- [![MCP Community Server](https://img.shields.io/badge/Model_Context_Protocol-Official_Community_Server-blue?style=flat-square)](https://github.com/modelcontextprotocol/servers)
9
- [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/bgauryy/octocode-mcp)
10
- [![Trust Score](https://archestra.ai/mcp-catalog/api/badge/quality/bgauryy/octocode-mcp)](https://archestra.ai/mcp-catalog/bgauryy__octocode-mcp)
11
-
12
- </div>
1
+ # Octocode MCP Server
13
2
 
14
- ---
15
-
16
- ## 📑 Table of Contents
17
-
18
- - [Why Octocode MCP?](#-why-octocode-mcp)
19
- - [Quick Start](#-quick-start-2-minutes)
20
- - [How to Choose the Right Tool](#-how-to-choose-the-right-tool)
21
- - [Available Tools](#-available-research-tools)
22
- - [Platform Setup](#-platform-setup)
23
- - [Real-World Examples](#-real-world-examples)
24
- - [Advanced Configuration](#-advanced-configuration)
25
- - [Documentation & Resources](#-documentation--resources)
26
- - [Community & Support](#-community--support)
27
-
28
- ---
29
-
30
- ## Why Octocode MCP?
3
+ **Model Context Protocol Server for GitHub Code Research**
31
4
 
32
- ### The Context Gap Problem
5
+ [![NPM Version](https://img.shields.io/npm/v/octocode-mcp)](https://www.npmjs.com/package/octocode-mcp)
6
+ [![License](https://img.shields.io/npm/l/octocode-mcp)](../../LICENSE)
33
7
 
34
- Most AI assistants today have **generic knowledge** but lack **deep, contextual understanding** of real-world code solutions. When you need to:
8
+ MCP server implementation providing five specialized tools for AI-driven GitHub code research with enterprise-grade security and token optimization.
35
9
 
36
- - Implement complex features with proven patterns
37
- - ✅ Debug difficult issues by finding similar solutions
38
- - ✅ Understand how enterprise-scale systems work
39
- - ✅ Learn best practices from production code
40
- - ✅ Create comprehensive technical documentation
10
+ **For general overview and getting started, see the [main README](../../README.md).**
41
11
 
42
- **You hit a wall.** Generic AI knowledge isn't enough.
43
-
44
- ### The Octocode Solution
45
-
46
- Octocode MCP bridges this gap by providing AI assistants with **real-time access to millions of GitHub repositories**, enabling:
47
-
48
- | Capability | What You Get |
49
- |-----------|-------------|
50
- | **🔍 Smart Code Discovery** | Find relevant implementations using semantic search across millions of repositories |
51
- | **📊 Progressive Research** | AI-powered workflows that build comprehensive understanding through multiple queries |
52
- | **🏗️ Ecosystem Understanding** | Analyze how real organizations structure complex systems and solve hard problems |
53
- | **📚 Real-World Examples** | Access production code, not toy examples or outdated tutorials |
54
- | **🔒 Enterprise-Grade Security** | Automatic content sanitization, respects GitHub permissions, redacts sensitive data |
55
- | **⚡ Token-Efficient** | Smart content minification reduces token usage by up to 70% |
56
-
57
- ### Perfect For
12
+ ---
58
13
 
59
- - **🎨 Code Creation**: Get context about patterns, libraries, and implementations before writing code
60
- - **🐛 Complex Bug Fixes**: Find real solutions for complex bugs by analyzing how others solved similar issues
61
- - **🏢 Enterprise Solutions**: Understand how large-scale systems are architected and maintained
62
- - **📖 Documentation**: Enrich technical docs with real, tested code examples
63
- - **🎓 Learning**: Discover how experienced developers tackle challenging problems
64
- - **🔍 Technology Research**: Research new frameworks, patterns, and best practices
14
+ ## Table of Contents
65
15
 
66
- ### See The Difference
16
+ - [Installation](#installation)
17
+ - [API Reference](#api-reference)
18
+ - [githubSearchCode](#githubsearchcode)
19
+ - [githubSearchRepositories](#githubsearchrepositories)
20
+ - [githubViewRepoStructure](#githubviewrepostructure)
21
+ - [githubGetFileContent](#githubgetfilecontent)
22
+ - [githubSearchPullRequests](#githubsearchpullrequests)
23
+ - [Configuration](#configuration)
24
+ - [Authentication](#authentication)
25
+ - [Advanced Usage](#advanced-usage)
26
+ - [Documentation](#documentation)
67
27
 
68
- **[ Live Demo: ThreeJS Code Creation Comparison](https://octocode-sonnet4-gpt5-comparisson.vercel.app/)**
28
+ ---
69
29
 
70
- This interactive comparison shows how Octocode MCP transforms AI assistants from providing generic code suggestions to delivering expert-level, context-rich implementations.
30
+ ## Installation
71
31
 
72
- ---
32
+ ### NPM
73
33
 
74
- ## 🚀 Quick Start (2 Minutes)
34
+ ```bash
35
+ npm install octocode-mcp
36
+ ```
75
37
 
76
- ### Prerequisites
38
+ ### NPX (Recommended for MCP)
77
39
 
78
- - **Node.js** >= 18.12.0
79
- - **GitHub Authentication** (choose one):
80
- - [GitHub CLI](https://cli.github.com/) (recommended): `gh auth login`
81
- - Personal Access Token: Create at [github.com/settings/tokens](https://github.com/settings/tokens) with `repo`, `read:user`, `read:org` scopes
40
+ ```bash
41
+ npx octocode-mcp@latest
42
+ ```
82
43
 
83
- ### Installation
44
+ ### Configuration
84
45
 
85
- Add Octocode MCP to your AI assistant's configuration:
46
+ Add to your MCP client configuration:
86
47
 
87
48
  ```json
88
49
  {
@@ -95,405 +56,529 @@ Add Octocode MCP to your AI assistant's configuration:
95
56
  }
96
57
  ```
97
58
 
98
- **Need help finding your config file?** See [Platform Setup](#-platform-setup) for detailed instructions for Claude Desktop, Cursor, Windsurf, and VS Code.
99
-
100
- **Using a Personal Access Token?** Add it to the `env` section (see Platform Setup for examples).
101
-
102
- ### Verify Installation
103
-
104
- After setup, try this in your AI assistant:
105
-
106
- ```
107
- "Search for React hooks implementations in popular repositories"
108
- ```
109
-
110
- If you see search results from GitHub repositories, you're all set! 🎉
59
+ **Platform-specific setup**: See [main README - Platform Setup](../../README.md#platform-specific-setup)
111
60
 
112
61
  ---
113
62
 
114
- ## 🧭 How to Choose the Right Tool
63
+ ## API Reference
115
64
 
116
- Use this decision tree to select the perfect tool for your task:
65
+ ### githubSearchCode
117
66
 
118
- ```
119
- 📝 What do you want to do?
120
-
121
- ├─ 🔍 Find code or examples
122
- │ ├─ Know what you're looking for → githubSearchCode
123
- │ └─ Need to discover repositories first → githubSearchRepositories
124
-
125
- ├─ 📂 Explore a repository
126
- │ ├─ See file/folder structure → githubViewRepoStructure
127
- │ └─ Read specific files → githubGetFileContent
128
-
129
- ├─ 📚 Understand changes/history
130
- │ └─ Analyze pull requests → githubSearchPullRequests
131
-
132
- └─ Not sure where to start?
133
- └─ Start broad with githubSearchRepositories → then narrow down
134
- ```
67
+ Search for code implementations across GitHub repositories.
135
68
 
136
- ### Quick Reference Table
69
+ #### Parameters
137
70
 
138
- | Goal | Tool | What It Returns |
139
- |------|------|----------------|
140
- | **Find specific code** | `githubSearchCode` | Code snippets with context |
141
- | **Discover repositories** | `githubSearchRepositories` | Repo list with stars, topics |
142
- | **Explore structure** | `githubViewRepoStructure` | File/folder tree |
143
- | **Read files** | `githubGetFileContent` | Full or partial file content |
144
- | **Analyze changes** | `githubSearchPullRequests` | PR details, diffs, discussions |
71
+ ```typescript
72
+ interface GithubSearchCodeParams {
73
+ // Query parameters
74
+ keywordsToSearch: string[]; // Required: Search terms (AND logic)
75
+
76
+ // Filters
77
+ owner?: string; // Repository owner/organization
78
+ repo?: string; // Specific repository name
79
+ path?: string; // Directory path filter
80
+ filename?: string; // Filename pattern (case-insensitive)
81
+ extension?: string; // File extension without dot (e.g., "ts", "js")
82
+
83
+ // Search mode
84
+ match?: "file" | "path"; // "file" = search IN content (default)
85
+ // "path" = search file/directory names
86
+
87
+ // Control
88
+ limit?: number; // Max results: 1-20 (default: 10)
89
+ minify?: boolean; // Minify results (default: true)
90
+ sanitize?: boolean; // Sanitize secrets (default: true)
91
+ }
92
+ ```
145
93
 
146
- ---
94
+ #### Response
147
95
 
148
- ## 🛠️ Available Research Tools
96
+ ```typescript
97
+ interface GithubSearchCodeResponse {
98
+ results: Array<{
99
+ path: string; // File path
100
+ repository: {
101
+ owner: string;
102
+ name: string;
103
+ full_name: string;
104
+ html_url: string;
105
+ description: string;
106
+ stars: number;
107
+ };
108
+ text_matches?: Array<{ // Only when match="file"
109
+ fragment: string; // Code snippet with match
110
+ matches: Array<{
111
+ text: string;
112
+ indices: [number, number];
113
+ }>;
114
+ }>;
115
+ }>;
116
+ total_count: number;
117
+ incomplete_results: boolean;
118
+ }
119
+ ```
149
120
 
150
- ### Default Tools (Always Enabled)
121
+ #### Best Practices
151
122
 
152
- #### `githubSearchCode`
153
- **Find specific code implementations across repositories**
123
+ - **Discovery**: Use `match="path"` for fast file location (25x faster, 20 tokens vs 500)
124
+ - **Analysis**: Use `match="file"` with low `limit` (5-10) for detailed matches
125
+ - **Scope**: Always specify `owner`/`repo` when possible to avoid rate limits
126
+ - **Keywords**: Use specific terms (function names, error messages) over generic terms
154
127
 
155
- **Best for:**
156
- - Finding how a function/class is implemented
157
- - Discovering code patterns and examples
158
- - Researching library usage
128
+ #### Examples
159
129
 
160
- **Not recommended for:**
161
- - Finding repositories (use `githubSearchRepositories`)
162
- - Reading full files (use `githubGetFileContent`)
130
+ ```typescript
131
+ // Fast discovery - find files with "auth" in path
132
+ {
133
+ keywordsToSearch: ["auth"],
134
+ match: "path"
135
+ }
163
136
 
164
- **Example Prompts:**
165
- - "Find React useEffect cleanup patterns"
166
- - "Show me OAuth2 implementation in Node.js"
167
- - "Search for error handling in GraphQL resolvers"
137
+ // Detailed search - find OAuth implementations
138
+ {
139
+ owner: "passportjs",
140
+ repo: "passport",
141
+ keywordsToSearch: ["OAuth2", "strategy"],
142
+ extension: "js",
143
+ limit: 5
144
+ }
168
145
 
169
- **Arguments:**
170
- ```typescript
146
+ // Targeted search - find exports in specific directory
171
147
  {
172
- keywordsToSearch: string[]; // Required: Terms to search for
173
- owner?: string; // Filter by repo owner
174
- repo?: string; // Filter by specific repo
175
- path?: string; // Search in specific directory
176
- filename?: string; // Filter by filename
177
- extension?: string; // Filter by file type
178
- limit?: number; // Max results (1-20)
148
+ owner: "facebook",
149
+ repo: "react",
150
+ path: "packages/react/src",
151
+ keywordsToSearch: ["export", "function"],
152
+ match: "file"
179
153
  }
180
154
  ```
181
155
 
182
156
  ---
183
157
 
184
- #### `githubSearchRepositories`
185
- **Discover repositories by topic, language, or description**
186
-
187
- **Best for:**
188
- - Finding projects in specific domains
189
- - Discovering popular implementations
190
- - Research technology ecosystems
158
+ ### githubSearchRepositories
191
159
 
192
- **Not recommended for:**
193
- - Searching inside code (use `githubSearchCode`)
194
- - Reading repository content (use `githubViewRepoStructure` first)
160
+ Discover GitHub repositories by topics, keywords, or metadata.
195
161
 
196
- **Example Prompts:**
197
- - "Find popular React component libraries"
198
- - "Show me microservices examples with high stars"
199
- - "Discover AI agent frameworks"
162
+ #### Parameters
200
163
 
201
- **Arguments:**
202
164
  ```typescript
203
- {
204
- keywordsToSearch?: string[]; // Search in name/description
205
- topicsToSearch?: string[]; // Search by GitHub topics
206
- owner?: string; // Filter by owner
207
- stars?: string; // e.g., ">1000", "100..500"
208
- language?: string; // e.g., "TypeScript"
209
- sort?: string; // "stars" | "forks" | "updated"
210
- limit?: number; // Max results (1-20)
165
+ interface GithubSearchRepositoriesParams {
166
+ // Query modes (use one or both)
167
+ topicsToSearch?: string[]; // GitHub topic tags (exact match, curated)
168
+ keywordsToSearch?: string[]; // Search name/description/README (AND logic)
169
+
170
+ // Filters
171
+ owner?: string; // Organization or user
172
+ stars?: string; // Examples: ">1000", "100..500", "<100"
173
+ language?: string; // Programming language (e.g., "TypeScript")
174
+ size?: string; // Repo size in KB (e.g., ">1000", "<500")
175
+ created?: string; // Creation date (e.g., ">=2024-01-01")
176
+ updated?: string; // Last update date
177
+
178
+ // Search scope
179
+ match?: ("name" | "description" | "readme")[]; // Fields to search (OR logic)
180
+
181
+ // Control
182
+ sort?: "stars" | "forks" | "updated" | "best-match";
183
+ limit?: number; // Max results: 1-20 (default: 5)
211
184
  }
212
185
  ```
213
186
 
214
- ---
215
-
216
- #### `githubViewRepoStructure`
217
- **Explore repository file and folder structure**
218
-
219
- **Best for:**
220
- - Understanding project organization
221
- - Finding where specific code lives
222
- - Navigating before reading files
223
-
224
- **Not recommended for:**
225
- - Reading file contents (use `githubGetFileContent`)
226
- - Searching across repos (use `githubSearchCode`)
187
+ #### Response
227
188
 
228
- **Example Prompts:**
229
- - "Show me the structure of the React repository"
230
- - "What's in the src folder of this project?"
231
- - "Explore the components directory"
232
-
233
- **Arguments:**
234
189
  ```typescript
235
- {
236
- owner: string; // Required: Repository owner
237
- repo: string; // Required: Repository name
238
- path?: string; // Directory path (default: root)
239
- depth?: number; // 1 = current dir, 2 = with subdirs
240
- branch?: string; // Branch name (default: main branch)
190
+ interface GithubSearchRepositoriesResponse {
191
+ results: Array<{
192
+ owner: string;
193
+ name: string;
194
+ full_name: string;
195
+ description: string;
196
+ html_url: string;
197
+ stars: number;
198
+ forks: number;
199
+ language: string;
200
+ topics: string[];
201
+ created_at: string;
202
+ updated_at: string;
203
+ size: number; // KB
204
+ }>;
205
+ total_count: number;
241
206
  }
242
207
  ```
243
208
 
244
- ---
209
+ #### Best Practices
245
210
 
246
- #### `githubGetFileContent`
247
- **Read file contents with smart context retrieval**
211
+ - **Discovery**: Use `topicsToSearch` for curated, high-quality results
212
+ - **Quality**: Filter with `stars=">1000"` for production-ready code
213
+ - **Maintenance**: Use `updated` filter for actively maintained projects
214
+ - **Scope**: Combine topics + stars for best results
248
215
 
249
- **Best for:**
250
- - Reading specific files
251
- - Getting code context around matches
252
- - Line-range based reading
216
+ #### Examples
253
217
 
254
- **Not recommended for:**
255
- - Searching across files (use `githubSearchCode`)
256
- - Finding files (use `githubViewRepoStructure`)
218
+ ```typescript
219
+ // Find quality TypeScript CLI tools
220
+ {
221
+ topicsToSearch: ["typescript", "cli"],
222
+ stars: ">1000",
223
+ sort: "stars"
224
+ }
257
225
 
258
- **Example Prompts:**
259
- - "Show me the README of this repo"
260
- - "Read the authentication module"
261
- - "Get lines 50-100 of this file"
226
+ // Recent authentication libraries
227
+ {
228
+ keywordsToSearch: ["authentication", "jwt"],
229
+ language: "JavaScript",
230
+ updated: ">=2024-01-01",
231
+ limit: 10
232
+ }
262
233
 
263
- **Arguments:**
264
- ```typescript
234
+ // Organization's popular repos
265
235
  {
266
- owner: string; // Required: Repository owner
267
- repo: string; // Required: Repository name
268
- path: string; // Required: File path
269
- startLine?: number; // Optional: Start reading from line
270
- endLine?: number; // Optional: End reading at line
271
- matchString?: string; // Optional: Find and return context around match
272
- matchStringContextLines?: number; // Lines of context (default: 5)
273
- branch?: string; // Branch name
236
+ owner: "facebook",
237
+ sort: "stars",
238
+ limit: 20
274
239
  }
275
240
  ```
276
241
 
277
242
  ---
278
243
 
279
- ### Advanced Tools (Optional)
280
-
281
- #### `githubSearchPullRequests`
282
- **Analyze pull requests, changes, and discussions**
244
+ ### githubViewRepoStructure
283
245
 
284
- **Enable with:** `export ENABLE_TOOLS="githubSearchPullRequests"`
246
+ Explore repository directory structure with file sizes.
285
247
 
286
- **Best for:**
287
- - Understanding how features were implemented
288
- - Learning from code review discussions
289
- - Analyzing bug fixes and solutions
248
+ #### Parameters
290
249
 
291
- **Not recommended for:**
292
- - Current code search (use `githubSearchCode`)
293
- - General repository discovery (use `githubSearchRepositories`)
250
+ ```typescript
251
+ interface GithubViewRepoStructureParams {
252
+ // Required
253
+ owner: string; // Repository owner
254
+ repo: string; // Repository name
255
+ branch: string; // Branch, tag, or SHA
256
+
257
+ // Optional
258
+ path?: string; // Directory path (default: "" = root)
259
+ depth?: 1 | 2; // Exploration depth (default: 1)
260
+ // 1 = current directory only
261
+ // 2 = includes subdirectories
262
+ }
263
+ ```
294
264
 
295
- **Example Prompts:**
296
- - "Show me recent authentication PRs"
297
- - "Find PRs that fixed performance issues"
298
- - "Analyze how they implemented dark mode"
265
+ #### Response
299
266
 
300
- **Arguments:**
301
267
  ```typescript
302
- {
303
- owner?: string; // Repository owner
304
- repo?: string; // Repository name
305
- prNumber?: number; // Specific PR number
306
- state?: "open" | "closed"; // PR state
307
- merged?: boolean; // Only merged PRs
308
- query?: string; // Free-text search
309
- limit?: number; // Max results (1-10)
310
- withContent?: boolean; // Include code diffs
311
- withComments?: boolean; // Include discussions
268
+ interface GithubViewRepoStructureResponse {
269
+ path: string; // Current directory path
270
+ files: Array<{
271
+ name: string;
272
+ path: string;
273
+ size: number; // Bytes
274
+ type: "file";
275
+ }>;
276
+ folders: Array<{
277
+ name: string;
278
+ path: string;
279
+ type: "dir";
280
+ files?: Array<...>; // Only when depth=2
281
+ folders?: Array<...>; // Only when depth=2
282
+ }>;
312
283
  }
313
284
  ```
314
285
 
315
- ---
316
-
317
- ## 🖥️ Platform Setup
286
+ #### Best Practices
318
287
 
319
- ### Claude Desktop
288
+ - **Start shallow**: Use `depth=1` for overview, then drill down
289
+ - **Navigate**: Use `path` to explore specific directories
290
+ - **Large repos**: Avoid `depth=2` on root of large repositories
320
291
 
321
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
292
+ #### Examples
322
293
 
323
- ```json
294
+ ```typescript
295
+ // Root overview
324
296
  {
325
- "mcpServers": {
326
- "octocode": {
327
- "command": "npx",
328
- "args": ["octocode-mcp@latest"]
329
- }
330
- }
297
+ owner: "facebook",
298
+ repo: "react",
299
+ branch: "main",
300
+ path: "",
301
+ depth: 1
331
302
  }
332
- ```
333
303
 
334
- **With Personal Access Token:**
335
- ```json
304
+ // Deep dive into specific directory
336
305
  {
337
- "mcpServers": {
338
- "octocode": {
339
- "command": "npx",
340
- "args": ["octocode-mcp@latest"],
341
- "env": {
342
- "GITHUB_TOKEN": "ghp_your_token_here"
343
- }
344
- }
345
- }
306
+ owner: "facebook",
307
+ repo: "react",
308
+ branch: "main",
309
+ path: "packages/react/src",
310
+ depth: 2
346
311
  }
347
312
  ```
348
313
 
349
- Restart Claude Desktop to activate.
350
-
351
314
  ---
352
315
 
353
- ### Cursor
316
+ ### githubGetFileContent
354
317
 
355
- 1. Open **Cursor Settings** **Features** → **MCP Servers**
356
- 2. Click **"+ Add New Global MCP Server"**
357
- 3. Enter configuration:
318
+ Read file contents with smart extraction capabilities.
358
319
 
359
- ```json
360
- {
361
- "mcpServers": {
362
- "octocode": {
363
- "command": "npx",
364
- "args": ["octocode-mcp@latest"]
365
- }
366
- }
320
+ #### Parameters
321
+
322
+ ```typescript
323
+ interface GithubGetFileContentParams {
324
+ // Required
325
+ owner: string; // Repository owner
326
+ repo: string; // Repository name
327
+ path: string; // File path from repository root
328
+
329
+ // Optional
330
+ branch?: string; // Branch, tag, or SHA (default: default branch)
331
+
332
+ // Extraction modes (choose one)
333
+ // Mode 1: Pattern matching (most efficient)
334
+ matchString?: string; // Search pattern
335
+ matchStringContextLines?: number; // Context lines around match (1-50, default: 5)
336
+
337
+ // Mode 2: Line range
338
+ startLine?: number; // Start line (1-indexed)
339
+ endLine?: number; // End line (1-indexed)
340
+
341
+ // Mode 3: Full content
342
+ fullContent?: boolean; // Return entire file (default: false)
343
+
344
+ // Control
345
+ minified?: boolean; // Minify content (default: true)
346
+ sanitize?: boolean; // Sanitize secrets (default: true)
367
347
  }
368
348
  ```
369
349
 
370
- 4. Save and restart Cursor
350
+ #### Response
371
351
 
372
- **Access in Cursor:** Use the Composer (⌘+L on Mac) and select "Agent" mode to automatically use Octocode tools.
352
+ ```typescript
353
+ interface GithubGetFileContentResponse {
354
+ path: string;
355
+ content: string; // File content (full or extracted)
356
+ size: number; // Original file size in bytes
357
+ encoding: string;
358
+ sha: string;
359
+ extraction_mode: "pattern" | "range" | "full";
360
+ matches_found?: number; // When using matchString
361
+ }
362
+ ```
373
363
 
374
- ---
364
+ #### Best Practices
375
365
 
376
- ### Windsurf
366
+ - **Token efficiency**: Use `matchString` for 85% token savings vs `fullContent`
367
+ - **Large files**: Always use extraction (matchString or line range), never fullContent
368
+ - **Config files**: Set `minified=false` for JSON/YAML to preserve formatting
369
+ - **Precision**: Use `matchString` from `githubSearchCode` text_matches for accurate targeting
377
370
 
378
- Add to `~/.codeium/windsurf/model_config.json`:
371
+ #### Examples
379
372
 
380
- ```json
373
+ ```typescript
374
+ // Extract function with context (BEST - most efficient)
381
375
  {
382
- "mcpServers": {
383
- "octocode": {
384
- "command": "npx",
385
- "args": ["octocode-mcp@latest"]
386
- }
387
- }
376
+ owner: "jaredhanson",
377
+ repo: "passport",
378
+ path: "lib/strategies/oauth2.js",
379
+ matchString: "authorize",
380
+ matchStringContextLines: 20
381
+ }
382
+
383
+ // Read specific line range
384
+ {
385
+ owner: "facebook",
386
+ repo: "react",
387
+ path: "packages/react/src/React.js",
388
+ startLine: 1,
389
+ endLine: 50
388
390
  }
389
- ```
390
391
 
391
- Restart Windsurf after configuration.
392
+ // Read config file (preserve formatting)
393
+ {
394
+ owner: "microsoft",
395
+ repo: "TypeScript",
396
+ path: "tsconfig.json",
397
+ fullContent: true,
398
+ minified: false
399
+ }
400
+ ```
392
401
 
393
402
  ---
394
403
 
395
- ### VS Code
404
+ ### githubSearchPullRequests
396
405
 
397
- **One-Click Installation:**
406
+ Analyze pull requests, code changes, and discussions.
398
407
 
399
- [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_MCP-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22octocode-mcp%40latest%22%5D%7D)
408
+ **Status**: Optional tool (disabled by default)
400
409
 
401
- **Manual Installation:**
410
+ **Enable**: Set `ENABLE_TOOLS="githubSearchPullRequests"` in environment
402
411
 
403
- Add to User Settings (JSON) — Press `Ctrl/Cmd + Shift + P` → `Preferences: Open User Settings (JSON)`:
412
+ #### Parameters
404
413
 
405
- ```json
406
- {
407
- "mcp": {
408
- "servers": {
409
- "octocode": {
410
- "command": "npx",
411
- "args": ["octocode-mcp@latest"]
412
- }
413
- }
414
- }
414
+ ```typescript
415
+ interface GithubSearchPullRequestsParams {
416
+ // Identification (use one)
417
+ owner?: string; // Repository owner
418
+ repo?: string; // Repository name
419
+ prNumber?: number; // Direct PR fetch (fastest, bypasses search)
420
+
421
+ // Search filters (when not using prNumber)
422
+ state?: "open" | "closed";
423
+ merged?: boolean; // Only merged PRs (requires state="closed")
424
+ query?: string; // Free-text search in title/body/comments
425
+ match?: ("title" | "body" | "comments")[]; // Search scope
426
+
427
+ // Author and reviewers
428
+ author?: string;
429
+ assignee?: string;
430
+ reviewedBy?: string;
431
+
432
+ // Metadata filters
433
+ label?: string | string[]; // Label filter (OR logic if array)
434
+ base?: string; // Target branch
435
+ head?: string; // Source branch
436
+
437
+ // Date filters
438
+ created?: string; // Creation date (e.g., ">=2024-01-01")
439
+ updated?: string; // Last update date
440
+ merged?: string; // Merge date
441
+ closed?: string; // Close date
442
+
443
+ // Engagement filters
444
+ comments?: number | string; // Comment count (e.g., ">5", "10..20")
445
+ reactions?: number | string; // Reaction count
446
+
447
+ // Control
448
+ sort?: "created" | "updated" | "best-match";
449
+ order?: "asc" | "desc";
450
+ limit?: number; // Max results: 1-10 (default: 5)
451
+
452
+ // Content inclusion (token expensive)
453
+ withContent?: boolean; // Include code diffs (default: false)
454
+ withComments?: boolean; // Include comment threads (default: false)
415
455
  }
416
456
  ```
417
457
 
418
- ---
458
+ #### Response
419
459
 
420
- ## 📺 Real-World Examples
421
-
422
- ### Example 1: Deep Code Research
423
- **Prompt:** "Explain deeply how React hooks work under the hood, using information from code and documents."
424
-
425
- Watch the AI use Octocode to:
426
- 1. Search React repository for hooks implementation
427
- 2. Analyze the source code structure
428
- 3. Read specific files for technical details
429
- 4. Synthesize comprehensive explanation
460
+ ```typescript
461
+ interface GithubSearchPullRequestsResponse {
462
+ results: Array<{
463
+ number: number;
464
+ title: string;
465
+ state: "open" | "closed";
466
+ merged: boolean;
467
+ author: string;
468
+ html_url: string;
469
+ created_at: string;
470
+ updated_at: string;
471
+ merged_at?: string;
472
+ body: string;
473
+
474
+ // When withContent=true
475
+ files?: Array<{
476
+ filename: string;
477
+ status: "added" | "modified" | "removed";
478
+ additions: number;
479
+ deletions: number;
480
+ changes: number;
481
+ patch?: string; // Diff content
482
+ }>;
483
+
484
+ // When withComments=true
485
+ comments?: Array<{
486
+ author: string;
487
+ body: string;
488
+ created_at: string;
489
+ }>;
490
+ }>;
491
+ }
492
+ ```
430
493
 
431
- **[📺 Watch on YouTube](https://www.youtube.com/watch?v=BCOpsRjAPU4&t=9s)**
494
+ #### Best Practices
432
495
 
433
- ---
496
+ - **Direct fetch**: Use `prNumber` for 10x faster retrieval
497
+ - **Production code**: Use `state="closed"` + `merged=true` for shipped features
498
+ - **Token management**:
499
+ - `withComments=false`: 50% token savings
500
+ - `withContent=false`: 80% token savings
501
+ - **Analysis**: Enable content/comments only when needed for deep analysis
434
502
 
435
- ### Example 2: Learn About AI Agents
436
- **Goal:** Create comprehensive context for building AI agents
503
+ #### Examples
437
504
 
438
- **[📺 Watch on YouTube](https://www.youtube.com/watch?v=rhQ3nTwU9kw)**
505
+ ```typescript
506
+ // Fetch specific PR with diffs (direct, fastest)
507
+ {
508
+ owner: "facebook",
509
+ repo: "react",
510
+ prNumber: 12345,
511
+ withContent: true
512
+ }
439
513
 
440
- ---
514
+ // Find merged authentication PRs
515
+ {
516
+ owner: "passportjs",
517
+ repo: "passport",
518
+ state: "closed",
519
+ merged: true,
520
+ query: "authentication",
521
+ limit: 5
522
+ }
441
523
 
442
- ### Example 3: Review Pull Requests
443
- **Goal:** Analyze how features are implemented through PR reviews
524
+ // Recent open PRs with discussions
525
+ {
526
+ owner: "microsoft",
527
+ repo: "TypeScript",
528
+ state: "open",
529
+ sort: "updated",
530
+ withComments: true,
531
+ limit: 10
532
+ }
444
533
 
445
- **[📺 Watch on YouTube](https://www.youtube.com/watch?v=rhQ3nTwU9kw)**
534
+ // Author's bug fixes
535
+ {
536
+ owner: "facebook",
537
+ repo: "react",
538
+ author: "gaearon",
539
+ label: "bug",
540
+ state: "closed",
541
+ merged: true
542
+ }
543
+ ```
446
544
 
447
545
  ---
448
546
 
449
- ### Example 4: Complex ThreeJS Implementation
450
- **See the dramatic difference** between generic AI and Octocode-enhanced AI:
547
+ ## Configuration
451
548
 
452
- **[ Interactive Demo](https://octocode-sonnet4-gpt5-comparisson.vercel.app/)**
549
+ ### Environment Variables
453
550
 
454
- This comparison shows how Octocode transforms AI from generic suggestions to expert-level implementations with real-world patterns.
551
+ | Variable | Type | Description | Default |
552
+ |----------|------|-------------|---------|
553
+ | `GITHUB_TOKEN` | string | Personal Access Token | Uses `gh` CLI if not set |
554
+ | `TOOLS_TO_RUN` | string | Comma-separated tool list (exclusive mode) | All default tools |
555
+ | `ENABLE_TOOLS` | string | Comma-separated tools to enable (additive) | None |
556
+ | `DISABLE_TOOLS` | string | Comma-separated tools to disable | None |
557
+ | `BETA` | "0" \| "1" | Enable experimental features | "0" |
455
558
 
456
- ---
559
+ **Notes**:
560
+ - `TOOLS_TO_RUN` is mutually exclusive with `ENABLE_TOOLS`/`DISABLE_TOOLS`
561
+ - Default tools: `githubSearchCode`, `githubSearchRepositories`, `githubViewRepoStructure`, `githubGetFileContent`
562
+ - Optional tools: `githubSearchPullRequests`
457
563
 
458
- ## ⚙️ Advanced Configuration
564
+ ### Tool Selection Examples
459
565
 
460
- ### Tool Selection
461
-
462
- **Run Specific Tools Only (Exclusive Mode):**
463
566
  ```bash
567
+ # Run only search tools (exclusive mode)
464
568
  export TOOLS_TO_RUN="githubSearchCode,githubSearchRepositories"
465
- ```
466
569
 
467
- **Enable Additional Tools (Additive Mode):**
468
- ```bash
570
+ # Enable PR search (additive mode)
469
571
  export ENABLE_TOOLS="githubSearchPullRequests"
470
- ```
471
572
 
472
- **Disable Specific Default Tools:**
473
- ```bash
573
+ # Disable structure exploration
474
574
  export DISABLE_TOOLS="githubViewRepoStructure"
475
- ```
476
575
 
477
- **Enable Experimental Features:**
478
- ```bash
576
+ # Enable experimental features
479
577
  export BETA="1"
480
578
  ```
481
579
 
482
- **Note:** `TOOLS_TO_RUN` cannot be combined with `ENABLE_TOOLS`/`DISABLE_TOOLS`.
580
+ ### MCP Configuration with Environment Variables
483
581
 
484
- ### Environment Variables
485
-
486
- | Variable | Description | Default |
487
- |----------|-------------|---------|
488
- | `GITHUB_TOKEN` | Personal Access Token for authentication | Uses `gh` CLI if not set |
489
- | `TOOLS_TO_RUN` | Comma-separated list of tools to run exclusively | All default tools |
490
- | `ENABLE_TOOLS` | Comma-separated list of additional tools to enable | None |
491
- | `DISABLE_TOOLS` | Comma-separated list of tools to disable | None |
492
- | `BETA` | Enable experimental features | `0` |
493
-
494
- ### Example Configuration with Environment Variables
495
-
496
- **Claude Desktop Config:**
497
582
  ```json
498
583
  {
499
584
  "mcpServers": {
@@ -502,101 +587,190 @@ export BETA="1"
502
587
  "args": ["octocode-mcp@latest"],
503
588
  "env": {
504
589
  "GITHUB_TOKEN": "ghp_your_token_here",
505
- "ENABLE_TOOLS": "githubSearchPullRequests"
590
+ "ENABLE_TOOLS": "githubSearchPullRequests",
591
+ "BETA": "1"
506
592
  }
507
593
  }
508
594
  }
509
595
  }
510
596
  ```
511
597
 
512
- ### Enterprise Features
598
+ ---
599
+
600
+ ## Authentication
601
+
602
+ ### Method 1: GitHub CLI (Recommended)
603
+
604
+ ```bash
605
+ # Install GitHub CLI
606
+ brew install gh # macOS
607
+ # or download from https://cli.github.com/
608
+
609
+ # Authenticate
610
+ gh auth login
611
+
612
+ # Verify
613
+ gh auth status
614
+ ```
615
+
616
+ **Pros**: Automatic token refresh, secure credential storage
617
+ **Cons**: Requires separate installation
618
+
619
+ ### Method 2: Personal Access Token
513
620
 
514
- **Content Sanitization:**
515
- - Automatic detection and redaction of API keys, tokens, passwords
516
- - Pattern-based secret detection across 50+ types
517
- - Configurable through security policies
621
+ 1. Create token at [github.com/settings/tokens](https://github.com/settings/tokens)
622
+ 2. Required scopes:
623
+ - `repo` - Access repositories (public and private)
624
+ - `read:user` - Read user profile
625
+ - `read:org` - Read organization data
626
+ 3. Add to environment: `GITHUB_TOKEN=ghp_your_token_here`
518
627
 
519
- **Token Optimization:**
520
- - Smart content minification (up to 70% reduction)
521
- - Partial file reading for large files
522
- - Structured, predictable response formats
628
+ **Pros**: Simple, direct control
629
+ **Cons**: Manual token management, no auto-refresh
523
630
 
524
- **Access Control:**
525
- - Respects your GitHub permissions
526
- - Works with public and private repositories
527
- - Organization-level access support
631
+ ### Rate Limits
528
632
 
529
- **Rate Limiting:**
530
- - Built-in GitHub API rate limit handling
531
- - Automatic retries with exponential backoff
532
- - Progress indicators for long operations
633
+ | Authentication | Rate Limit | Recommended For |
634
+ |----------------|------------|-----------------|
635
+ | Unauthenticated | 60 req/hour | Testing only |
636
+ | Authenticated | 5,000 req/hour | Production use |
637
+ | GitHub Enterprise | Custom | Enterprise deployments |
638
+
639
+ **Built-in handling**: Server automatically retries with exponential backoff on rate limit errors.
533
640
 
534
641
  ---
535
642
 
536
- ## 📚 Documentation & Resources
643
+ ## Advanced Usage
537
644
 
538
- | Resource | Description | Link |
539
- |----------|-------------|------|
540
- | **🌐 Official Website** | Interactive tutorials and community | [octocode.ai](https://octocode.ai) |
541
- | **📺 YouTube Channel** | Video tutorials and demos | [Octocode on YouTube](https://www.youtube.com/@Octocode-ai) |
542
- | **📖 Usage Guide** | 20+ examples and best practices | [USAGE_GUIDE.md](./docs/USAGE_GUIDE.md) |
543
- | **🔐 Authentication Guide** | Complete setup and enterprise features | [AUTHENTICATION.md](./docs/AUTHENTICATION.md) |
544
- | **🔧 Tool Schemas** | Complete API reference for all tools | [TOOL_SCHEMAS.md](./docs/TOOL_SCHEMAS.md) |
545
- | **🏗️ Architecture** | System design and performance details | [summary.md](./docs/summary.md) |
546
- | **📦 NPM Package** | Latest releases and changelog | [octocode-mcp on NPM](https://www.npmjs.com/package/octocode-mcp) |
645
+ ### Progressive Research Workflow
547
646
 
548
- ---
647
+ Recommended three-phase pattern for deep code understanding:
549
648
 
550
- ## 💬 Community & Support
649
+ ```typescript
650
+ // PHASE 1: DISCOVER - Find relevant repositories
651
+ const repos = await githubSearchRepositories({
652
+ topicsToSearch: ["microservices", "typescript"],
653
+ stars: ">1000"
654
+ });
655
+
656
+ // PHASE 2: EXPLORE - Understand structure
657
+ const structure = await githubViewRepoStructure({
658
+ owner: repos.results[0].owner,
659
+ repo: repos.results[0].name,
660
+ branch: "main",
661
+ path: "",
662
+ depth: 1
663
+ });
664
+
665
+ // PHASE 3: ANALYZE - Deep dive into code
666
+ const code = await githubSearchCode({
667
+ owner: repos.results[0].owner,
668
+ repo: repos.results[0].name,
669
+ keywordsToSearch: ["event", "handler"],
670
+ path: "src/services"
671
+ });
672
+
673
+ const fileContent = await githubGetFileContent({
674
+ owner: repos.results[0].owner,
675
+ repo: repos.results[0].name,
676
+ path: code.results[0].path,
677
+ matchString: "EventHandler",
678
+ matchStringContextLines: 30
679
+ });
680
+ ```
681
+
682
+ ### Token Optimization Strategies
551
683
 
552
- ### Get Help
684
+ 1. **Use pattern matching over full content**
685
+ ```typescript
686
+ // Good: 85% token savings
687
+ { matchString: "function", matchStringContextLines: 10 }
553
688
 
554
- - **💡 Feature Requests:** [GitHub Discussions](https://github.com/bgauryy/octocode-mcp/discussions/new?category=ideas)
555
- - **🐛 Issues & Bugs:** [GitHub Issues](https://github.com/bgauryy/octocode-mcp/issues)
556
- - **📖 Documentation:** [octocode.ai](https://octocode.ai)
557
- - **🎓 Video Tutorials:** [YouTube Channel](https://www.youtube.com/@Octocode-ai)
689
+ // Avoid: High token cost
690
+ { fullContent: true }
691
+ ```
558
692
 
559
- ### Contributing
693
+ 2. **Discovery before detailed search**
694
+ ```typescript
695
+ // Fast discovery (20 tokens)
696
+ { keywordsToSearch: ["auth"], match: "path" }
560
697
 
561
- We welcome contributions! Octocode MCP is open source and community-driven.
698
+ // Then detailed (500 tokens)
699
+ { keywordsToSearch: ["OAuth2"], match: "file", limit: 5 }
700
+ ```
562
701
 
563
- 1. **Fork the repository** on GitHub
564
- 2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
565
- 3. **Make your changes** with tests
566
- 4. **Run tests**: `yarn test`
567
- 5. **Submit a pull request**
702
+ 3. **Scope searches**
703
+ ```typescript
704
+ // Good: Scoped
705
+ { owner: "org", repo: "repo", path: "src" }
568
706
 
569
- For questions or suggestions, please open an issue on GitHub.
707
+ // Avoid: Unscoped (slow, generic results)
708
+ { keywordsToSearch: ["helper"] }
709
+ ```
570
710
 
571
- ### Show Your Support
711
+ ### Error Handling
572
712
 
573
- If Octocode MCP helps you build better AI applications, consider:
713
+ All tools return standard error responses:
714
+
715
+ ```typescript
716
+ interface ErrorResponse {
717
+ error: {
718
+ code: string;
719
+ message: string;
720
+ details?: any;
721
+ };
722
+ }
723
+ ```
574
724
 
575
- - **Star the repository** on [GitHub](https://github.com/bgauryy/octocode-mcp)
576
- - 🐦 **Share on Twitter** with #OctocodeMCP
577
- - 📝 **Write a blog post** about your experience
578
- - 🎥 **Create a tutorial** and share with the community
725
+ Common error codes:
726
+ - `RATE_LIMIT_EXCEEDED` - Wait for rate limit reset
727
+ - `AUTHENTICATION_FAILED` - Check GitHub credentials
728
+ - `NOT_FOUND` - Repository or file doesn't exist
729
+ - `VALIDATION_ERROR` - Invalid parameters
730
+ - `CONTENT_TOO_LARGE` - File exceeds size limits
731
+
732
+ ### Performance Characteristics
733
+
734
+ | Operation | Typical Latency | Token Cost (avg) |
735
+ |-----------|----------------|------------------|
736
+ | `githubSearchRepositories` | 200-500ms | 100-300 tokens |
737
+ | `githubSearchCode` (path) | 300-800ms | 50-200 tokens |
738
+ | `githubSearchCode` (file) | 500-1500ms | 500-2000 tokens |
739
+ | `githubViewRepoStructure` (depth=1) | 200-400ms | 100-500 tokens |
740
+ | `githubViewRepoStructure` (depth=2) | 400-1000ms | 500-2000 tokens |
741
+ | `githubGetFileContent` (pattern) | 300-600ms | 200-800 tokens |
742
+ | `githubGetFileContent` (full) | 400-1000ms | 1000-5000 tokens |
743
+ | `githubSearchPullRequests` (no content) | 400-800ms | 200-600 tokens |
744
+ | `githubSearchPullRequests` (with content) | 800-2000ms | 2000-10000 tokens |
579
745
 
580
746
  ---
581
747
 
582
- <div align="center">
748
+ ## Documentation
749
+
750
+ ### Comprehensive Resources
583
751
 
584
- ## 🌟 Recognition
752
+ - **[Main README](../../README.md)** - Getting started, overview, examples
753
+ - **[Usage Guide](./docs/USAGE_GUIDE.md)** - 20+ real-world examples
754
+ - **[Authentication Guide](./docs/AUTHENTICATION.md)** - Setup and troubleshooting
755
+ - **[Tool Schemas](./docs/TOOL_SCHEMAS.md)** - Complete JSON schemas
756
+ - **[Architecture](./docs/summary.md)** - System design and internals
585
757
 
586
- <a href="https://glama.ai/mcp/servers/@bgauryy/octocode-mcp">
587
- <img width="380" height="200" src="https://glama.ai/mcp/servers/@bgauryy/octocode-mcp/badge" alt="Octocode MCP on Glama" />
588
- </a>
758
+ ### External Links
759
+
760
+ - **[NPM Package](https://www.npmjs.com/package/octocode-mcp)** - Releases and changelog
761
+ - **[GitHub Repository](https://github.com/bgauryy/octocode-mcp)** - Source code
762
+ - **[Official Website](https://octocode.ai)** - Interactive tutorials
763
+ - **[YouTube Channel](https://www.youtube.com/@Octocode-ai)** - Video guides
589
764
 
590
765
  ---
591
766
 
592
- ### Built with ❤️ for developers by developers
767
+ ## Support
593
768
 
594
- **[Website](https://octocode.ai)** • **[GitHub](https://github.com/bgauryy/octocode-mcp)** • **[NPM](https://www.npmjs.com/package/octocode-mcp)**
769
+ - **Issues**: [github.com/bgauryy/octocode-mcp/issues](https://github.com/bgauryy/octocode-mcp/issues)
770
+ - **Discussions**: [github.com/bgauryy/octocode-mcp/discussions](https://github.com/bgauryy/octocode-mcp/discussions)
595
771
 
596
772
  ---
597
773
 
598
- *Octocode MCP is an official MCP Community Server*
599
-
600
- [![MCP Community](https://img.shields.io/badge/Model_Context_Protocol-Official_Community_Server-blue?style=for-the-badge)](https://github.com/modelcontextprotocol/servers)
774
+ ## License
601
775
 
602
- </div>
776
+ MIT - See [LICENSE](../../LICENSE) for details.