Skip to main content
Glama
local-pc-mcp

local-pc-mcp

by contra333
README.md
# local-pc-mcp

A stdio MCP server for working with files and Git repositories on your machine. Give a client a project directory and it can search source, read a PDF page, inspect a staged diff, or write a UTF-8 file there.

## Quickstart

Install Python 3.12 or later and Git. Install Poppler's `pdftoppm` on PATH for PDF page images and the full test suite. PDF text extraction uses pypdf.

From the project directory on Linux or macOS:

```sh
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -e '.[dev]'
mkdir -p example-workspace
export ALLOWED_ROOTS="$(pwd)/example-workspace"
local-pc-mcp
```

The server waits for MCP messages on standard input. Stop it with Ctrl+C. For a client that supports stdio servers, replace both paths below with absolute paths. The client launches the process itself.

```json
{
  "mcpServers": {
    "local-pc": {
      "command": "/absolute/path/to/local-pc-mcp/.venv/bin/local-pc-mcp",
      "env": { "ALLOWED_ROOTS": "/absolute/path/to/example-workspace" }
    }
  }
}
```

On Windows, create the environment with `py -3.12 -m venv .venv`, install with `.venv\Scripts\python.exe -m pip install -e ".[dev]"`, and point the client at `.venv\Scripts\local-pc-mcp.exe` using an absolute path. Escape backslashes in JSON. Set environment variables directly in the client configuration or shell. The server does not load dotenv files.

To check the connection, ask the client to call `file_list` with `{"path":"."}`. With one configured workspace, the result contains that directory's entries.

## Architecture and tools

The Python MCP SDK registers ten tools in `server.py`. Each tool resolves its path through `sandbox.py` before invoking a local filesystem operation or one of the modules below.

| Tools | Behavior |
| --- | --- |
| `file_list`, `file_read`, `file_write` | List one directory, preview text or PDF content, and create or overwrite a UTF-8 file in an existing directory. Ordinary text reads and writes are limited to 1 MiB. |
| `file_read_lines`, `file_search`, `file_json_get` | Page through text, search for a literal in names or text, or select a JSON value by JSON Pointer. Search visits up to 600 files and returns up to 30 matches. JSON input is limited to 4 MiB. |
| `file_read_pdf` | Extract up to 20 pages of text or render one page as a PNG. PDF input is limited to 256 MiB. Rendering uses Poppler and performs no OCR. |
| `git_status`, `git_diff`, `git_log` | Inspect a working tree, staged or unstaged changes, and up to 100 commits. Returned diff text is truncated at 1 MiB plus a marker. |

## Security model

- `ALLOWED_ROOTS` is a semicolon-separated list of absolute directories on all platforms. A missing or empty value makes tool calls fail closed. Relative paths require exactly one root. Canonical path checks resolve links before comparing directory boundaries.
- `gitops.py` checks the repository top level and builds argument lists for `status`, `diff`, `log`, and internal `rev-parse`. The caller supplies a path, a staging flag, or a count. Git runs without a shell and has a 30-second timeout.
- Run the server as a low-privilege user and expose only directories and repositories you trust. Clients can overwrite files in those directories. The checks run in the server process and rely on trusted local Git configuration, executables, and a filesystem that other users cannot change during a call. Directory listings and Git status can grow with the workspace.

## Tests

With the development dependencies, Git, and Poppler installed:

```sh
python -m pytest -q
```

The suite creates temporary directories, Git repositories, worktrees, and a sample PDF. It exercises path boundaries, size limits, the registered tool list, and the MCP client/server calls.

TDQS

B3.4/5.0

Scored across 10 tools

Disambiguation3/5

The file-reading tools overlap: file_read, file_read_lines, and file_read_pdf all read file content, and file_read even mentions a PDF preview that competes with file_read_pdf. Descriptions do help distinguish bounded line ranges and PDF-specific behavior, but an agent can easily misselect among the three read tools.

Naming Consistency4/5

Names consistently use snake_case with clear file_/git_ prefixes and mostly follow a resource_action pattern. Minor deviations like file_json_get (action not at the end) and compound suffixes in file_read_pdf/file_read_lines keep it from being perfectly uniform.

Tool Count5/5

Ten tools is well within the ideal 3-15 range and each tool maps to a distinct operation on local files or git repositories. The set is compact and purpose-scoped without obvious filler.

Completeness3/5

Read coverage is strong (text, lines, PDF, JSON pointer, search, list) and git inspection is covered, but the write lifecycle is incomplete: no delete, move, append, or directory creation, and git is read-only with no commit/add/branch operations. These are notable gaps agents cannot fully work around with the current surface.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues