Skip to main content
Glama
udittripathi

Local Code MCP Server

by udittripathi
README.md
# Local Code MCP Server (TypeScript)

A **Model Context Protocol (MCP) server** that provides LLMs with **safe, read-only access to a local codebase**.  
It allows AI assistants to answer questions like:

- Where is this functionality implemented?
- Which file contains this function?
- Search for usages of a specific API or keyword

All source code remains **local** — nothing is uploaded or shared externally.

---

## ✨ Features

- 🔒 Local-only, read-only access to files
- 📂 List files in a project
- 📄 Read file contents safely
- 🔍 Search code across the repository
- 🧭 Find function definitions
- 🧠 Zod-based schemas for reliable tool calls
- 🔌 Compatible with any MCP-enabled LLM client

---

## 🏗 Architecture

```
LLM Client (Claude / Cursor / Custom UI)
            │
            │  MCP (stdio)
            ▼
     MCP Server (Node + TypeScript)
            │
            ▼
     Local Project Files (read-only)
```

---

---

## 🧰 Available Tools

| Tool Name       | Description |
|-----------------|-------------|
| `list_files`    | List all files in the project |
| `read_file`     | Read a file by relative path |
| `search_code`   | Search text across source files |
| `find_function` | Locate function definitions |

---

## ⚙️ Prerequisites

- Node.js **18+**
- npm **9+**

---

## 🚀 Setup

### 1️⃣ Install Dependencies

```bash
npm install
```

---

### 2️⃣ Configure Project Root

Edit `src/config.ts` and set the absolute path of the project you want to query:

```ts
export const PROJECT_ROOT = "ABSOLUTE_PATH_TO_YOUR_PROJECT";
```

---

### 3️⃣ Build & Run

```bash
npm run build
npm start
```

---

## 🔌 Connecting an MCP Client

Example (Claude Desktop):

```json
{
  "mcpServers": {
    "local-code": {
      "command": "node",
      "args": ["<absolute-path>/dist/index.js"]
    }
  }
}
```

---

## 🔐 Security Model

- Read-only access
- Explicit project root allowlist
- Path traversal protection
- No network access
- No code upload

TDQS

B3.3/5.0

Scored across 4 tools

Disambiguation4/5

The tools have mostly distinct purposes: find_function locates specific function definitions, list_files enumerates files, read_file accesses file content, and search_code performs text searches. There is some potential overlap between find_function and search_code, as both involve searching code, but find_function is specialized for function definitions while search_code is general text search, making them distinguishable with careful reading of descriptions.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case: find_function, list_files, read_file, and search_code. This uniformity makes the tool set predictable and easy to understand, with no deviations in naming conventions.

Tool Count4/5

With 4 tools, the count is reasonable for a local code exploration server, covering basic file and code operations. It might be slightly thin for broader code management tasks, but it aligns well with the focused scope of navigating and reading a project like cal.com, without feeling overloaded or insufficient.

Completeness3/5

The tool set covers core read-only operations for code exploration: listing files, reading content, and searching. However, it lacks update, create, or delete capabilities, which might be expected for a full code management server. There are no obvious dead ends, but the surface is incomplete for more advanced workflows like modifying code or handling dependencies.

Maintenance

ActivityInactive
ResponsivenessNo issues