github-assistant-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@github-assistant-mcp what files are in my workspace?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GitHub Assistant MCP
A small, self-contained Model Context Protocol (MCP) server that exposes five read-focused tools to an AI coding assistant (e.g. OpenCode). It lets the assistant inspect a local workspace and pull a public GitHub profile over a clean, sandboxed stdio transport.
"A simple GitHub MCP server for OpenCode."
Table of Contents
Related MCP server: agenticscope
Overview
The server is a local MCP server started by OpenCode as a child process. It speaks the MCP protocol over stdio (stdin/stdout) and registers five tools. The assistant calls those tools; the server performs the work (filesystem reads, a git diff, or a GitHub API call) and returns structured text results.
Everything that touches the filesystem is confined to a single WORKSPACE_ROOT directory, so the assistant can never read or escape outside the project folder.
How It Works (Architecture)
┌─────────────────────────┐ stdio (MCP/JSON-RPC) ┌──────────────────────────────┐
│ │ ───────────────────────────────▶ │ github-assistant (this) │
│ OpenCode / AI │ tool call: get_github_profile │ │
│ Assistant │ │ ┌────────────────────────┐ │
│ │ ◀─────────────────────────────── │ │ McpServer │ │
│ - sees 5 tools │ result (JSON text) │ │ (server.ts) │ │
│ - calls them │ │ └───────────┬────────────┘ │
│ - sandbox enforced │ │ │ registerTools │
└─────────────────────────┘ └──────────────┼──────────────┘
▼
┌────────────────────────────────┐
│ tools.ts (5 tool handlers) │
└───┬──────┬──────┬──────┬─────┬──┘
┌───────────────┘ │ │ │ │
▼ ▼ ▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌─────────┐ ┌────────────┐
│ github.ts │ │ workspace.ts│ │ git.ts │ │ paths.ts │
│ GitHub API │ │ list/read/ │ │ git diff│ │ resolve │
│ (fetch) │ │ search │ │ │ │ sandbox │
└─────┬──────┘ └─────┬──────┘ └────┬────┘ └─────┬──────┘
│ │ │ │
▼ ▼ ▼ ▼
api.github.com WORKSPACE_ROOT/* git CLI config.ts
(files only) (cwd=root) WORKSPACE_ROOTData flow for a single tool call:
Assistant ──JSON-RPC request──▶ McpServer
│
▼
tool handler (tools.ts)
│ validates args with zod
▼
business logic (github / workspace / git / paths)
│ resolveWorkspacePath() enforces sandbox
▼
result helper (result.ts) → { content: [{ type:"text", text }] }
│
▼
Assistant ◀──JSON-RPC response── McpServerTransport & Lifecycle
Type:
local— OpenCode launches the server as a child process.Transport:
stdioviaserveStdio()from@modelcontextprotocol/server/stdio.Startup sequence:
node dist/server.jsis executed (declared inopencode.json) withcwd = ".".createServer()builds anMcpServernamedgithub-assistant(v1.0.0).registerTools(server)wires up the five tools.serveStdio(createServer)begins reading JSON-RPC messages from stdin and writing results to stdout.
Shutdown: OpenCode terminates the process when the session ends.
Because the process inherits OpenCode's working directory, WORKSPACE_ROOT resolves to the project directory (path.resolve(process.cwd())).
Tools Reference
All tools are registered in src/tools.ts and return MCP text results (JSON or plain text).
1. get_github_profile
Fetches the public GitHub profile of the hardcoded user (imshashwatsingh).
Inputs: none
Backend:
fetch()tohttps://api.github.com/users/imshashwatsinghwithAccept: application/vnd.github+jsonand aUser-Agentheader.Returns: username, name, company, location, bio, public repos/gists, followers, following, profile URL, created/updated timestamps.
File:
src/github.ts
2. list_files
Lists files under a workspace directory up to a depth.
Inputs:
path(default"."),maxDepth(0–10, default 3)Backend: recursive
collectFiles()insrc/workspace.ts— skips symlinks (no loops) and ignores configured directories (node_modules,.git,dist,.next,coverage,.cache). Capped atMAX_RESULTS(500).Returns: workspace root, file count, and relative file paths.
File:
src/workspace.ts
3. read_file
Reads a UTF-8 text file with optional line range.
Inputs:
path(required),startLine(optional),endLine(optional)Backend:
readWorkspaceFile()— enforces sandbox, rejects non-files, refuses files larger thanMAX_FILE_SIZE(1 MB), and refuses binary extensions. Returns numbered lines.Returns: file content with
line: textprefixes.File:
src/workspace.ts
4. search_context
Keyword search across the workspace with surrounding context.
Inputs:
query(required),path(default"."),maxResults(1–100, default 50),contextLines(0–10, default 2)Backend:
searchContext()collects files, filters text-only and size-bounded files, then scans each line (case-insensitive) and capturescontextLinesabove/below every match.Returns: query, search path, match count, and matches with file/line/context.
File:
src/workspace.ts
5. summarize_diff
Inspects the current Git diff and returns a structured summary.
Inputs:
staged(defaultfalse),base(optional git ref),path(optional file/dir),maxDiffChars(1000–200000, default 50000)Backend:
summarizeDiff()runsgit diff --no-ext-diff --unified=3(with--cached/ base ref / path filters) fromWORKSPACE_ROOT. Stats are parsed from the unified diff itself (no secondgitcall). Diff is truncated if it exceedsmaxDiffChars.Returns: files changed, insertions, deletions, per-file stats, and the raw diff — or
{ empty: true }when there are no changes.File:
src/git.ts
Security Model
The server is intentionally read-only and sandboxed:
Concern | Protection |
Path traversal ( |
|
Binary file reads |
|
Oversized files |
|
Symlink loops |
|
Directory blow-up | Listing/searching capped at |
Write / delete / exec | None. The server has no write, delete, or arbitrary shell-exec tools. The only spawned process is |
Network | Only one outbound call: the read-only GitHub public API for a fixed user. |
The sandbox boundary lives entirely in
paths.ts. Any new tool that touches the filesystem must route paths throughresolveWorkspacePath().
Project Walkthrough
Entry point —
src/server.tscreateServer()instantiatesMcpServerand callsregisterTools().serveStdio()bridges it to stdin/stdout.Tool registration —
src/tools.tsFiveserver.registerTool(...)calls. Each declares a description, a zod-validatedinputSchema, and an async handler. Handlers delegate to the modules below and wrap output withresult.tshelpers.Configuration —
src/config.tsCentral constants:WORKSPACE_ROOT(resolved fromprocess.cwd()), size/result limits, the GitHub username/URL, and ignore/binary sets.Path safety —
src/paths.tsresolveWorkspacePath()is the sandbox gate.toWorkspaceRelative()turns absolute paths back into workspace-relative strings for display.isProbablyTextFile()classifies files by extension.Workspace I/O —
src/workspace.tscollectFiles()(recursive listing),readWorkspaceFile()(safe read), andsearchContext()(keyword scan). All go throughresolveWorkspacePath().GitHub —
src/github.tsfetchGitHubProfile()calls the public API and maps the rawGitHubUserto the friendlierGitHubProfileshape.Git —
src/git.tssummarizeDiff()builds and runs thegit diffcommand;parseDiffStats()derives per-file insert/delete counts straight from the diff text.Results —
src/result.tsSmall helpers (textResult,errorResult,errorWithContext) standardize the MCPcontentenvelope and error flagging.
Configuration
opencode.json (project root) declares the server:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"github-assistant": {
"type": "local",
"command": ["node", "dist/server.js"],
"cwd": ".",
"enabled": true
}
}
}Inside the server, behavior is tuned via constants in src/config.ts:
Constant | Default | Meaning |
|
| Sandbox root (project dir) |
|
| Max readable file size |
|
| Max files from list/search |
|
| Profile target |
|
| Skipped while walking |
|
| Treated as non-text |
Building & Running
# install dependencies
npm install
# compile TypeScript -> dist/
npm run build
# start the server (used by opencode.json)
npm start
# run directly from source (no build step)
npm run dev
# the workspace must be a git repo for summarize_diff to work
git initOpenCode picks up the server automatically from opencode.json once built (dist/server.js).
File Structure
github_assistant_mcp/
├── opencode.json # MCP server declaration for OpenCode
├── package.json # scripts + dependencies
├── tsconfig.json # TypeScript config
├── src/
│ ├── server.ts # Entry point: create + serve McpServer
│ ├── tools.ts # Registers the 5 tools + handlers
│ ├── config.ts # Constants, limits, GitHub target
│ ├── paths.ts # Sandbox path resolution + helpers
│ ├── workspace.ts # list / read / search filesystem
│ ├── github.ts # GitHub profile fetch
│ ├── git.ts # git diff summary + stat parsing
│ └── result.ts # MCP result/error helpers
└── dist/ # Compiled output (npm run build)Limitations
get_github_profiletargets a single hardcoded user; it is not parameterized.summarize_diffreports working-tree changes only — untracked files are not shown bygit diff.Filesystem tools are confined to
WORKSPACE_ROOT; there is no cross-project access.All tools are read-only by design — no edits, deletions, or shell execution.
No authentication: the GitHub call uses the unauthenticated public API (rate-limited to 60 req/hr per IP).
Available Tools
5 toolsget_github_profileA
Get the public GitHub profile of imshashwatsingh.
Inputs: no named parameters.
list_filesA
List files in the workspace so the assistant can inspect the project before reading or summarizing it.
Inputs: path, maxDepth.
read_fileA
Read a text file from the workspace. Use list_files first to discover available files.
Inputs: path (required), endLine, startLine.
search_contextA
Search the workspace for a keyword or phrase. Returns matching files and surrounding lines so the assistant can understand relevant context.
Inputs: query (required), path, maxResults, contextLines.
summarize_diffA
Inspect the current Git diff and return a compact structured summary of changed files, additions, deletions, and the actual diff for the assistant to summarize.
Inputs: base, path, staged, maxDiffChars.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
The tools are clearly distinct: one fetches GitHub profile data, while the others handle local workspace file operations (listing, reading, searching, diffing). No functional overlap exists between them.
All tool names follow a consistent 'verb_noun' pattern (e.g., list_files, read_file, summarize_diff). The single compound name 'get_github_profile' still adheres to the same structure, maintaining a uniform convention.
Five tools is a reasonable number for a focused assistant, neither too sparse nor overwhelming. However, the mix leans heavily toward workspace operations rather than GitHub-specific actions, which slightly reduces appropriateness for the server's stated purpose.
The tool surface is severely incomplete for a GitHub assistant: it only covers profile retrieval and local file operations. Core GitHub workflows like issues, pull requests, repository management, and code search are entirely absent, making the toolset insufficient for its intended domain.
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for AI coding agents to inspect repositories, audit code quality, route engineering skills, and plan safe issue/PR workflows.1MIT
- AlicenseNot gradedqualityCmaintenanceA read-only MCP server that provides AI agents with live, structured workspace awareness, including project listing, git status, and budgeted context packing, minimizing token usage.3 npm2MIT
- AlicenseBqualityDmaintenanceA read-only MCP server that exposes a local code workspace to AI clients via stdio, providing file browsing and text search capabilities with path safety rules.1MIT
- AlicenseNot gradedqualityDmaintenanceA local MCP server that gives AI agents access to developer tooling — GitHub (read-only), documentation search, and web research — via stdio transport.MIT