octocounts-mcp
This server lets an AI agent get and compare GitHub SLOC reports from OctoCounts.
Analyze a repository: Use
analyze_repoto fetch SLOC totals for any public GitHub repo by URL orowner/repo.Pin to a version: Optionally pass
refto analyze a specific branch, tag, or commit SHA.Compare two repos: Use
compare_reposto compare SLOC totals between two public repositories.Compare versions: Optionally pass
left_refand/orright_refto compare specific branches, tags, or commits.
Provides access to SLOC reports for public GitHub repositories, enabling agents and developer assistants to retrieve file, line, code, comment, and blank counts per language for any branch, tag, or commit.
OctoCounts – GitHub SLOC Counter
GitHub shows language bars. OctoCounts shows the actual line counts.
GitHub's sidebar shows language percentages, but misses actual file and line counts. OctoCounts adds this missing SLOC (Source Lines of Code) view to public repos without cloning.
Install the extension for stats directly on GitHub, or use the web app for public GitHub repositories. It downloads the repo archive, runs tokei, and caches the results without downloading Git history.
Use OctoCounts
Surface | Use it for |
Analyze public GitHub repositories and share a live report or a fixed saved result. | |
Show SLOC directly inside GitHub's repository sidebar in Chrome, Edge, or Firefox. | |
See aggregate report totals, largest repos, language coverage, and source breakdown. | |
Comment SLOC changes on pull requests. | |
Run | |
Give agents and developer assistants access to SLOC reports. | |
Add a live SLOC badge that links to the repository report page. | |
Original research: a 10-repository study of how test/doc/generated-file filtering affects SLOC counts. |
Related MCP server: github-mcp
Preview
Why?
Sometimes you just want to know whether a repo is 2k lines, 200k lines, or a weekend-devouring monolith. GitHub already has the repo, the language stats, and the sidebar. OctoCounts fills in the missing numbers.
What it does
Adds a browser extension card to GitHub repo pages with files, total lines, code, comments, blanks, and language count
Provides a web app where you can paste any public GitHub repo URL
Resolves any branch, tag, or commit SHA — pins results to an exact commit so the cache is actually meaningful
Downloads the GitHub archive tarball instead of cloning, without Git history
Counts files, lines, code, comments, and blanks per language via tokei
Caches reports by repository, commit, tokei version, and analysis options — matching runs can reuse saved results
Queues analysis jobs so concurrent requests don't bring the server to its knees
Exports reports as plain text, JSON, or a shareable PNG card
Live repository links follow the latest cached public report. Fixed result links bind a saved report and commit, but saved records are subject to cache retention and may expire or be replaced; export JSON or text for long-term archival.
Counting scope
Every OctoCounts surface — the web app, badges, the browser extension, the CLI, the MCP server, and the indexed public report pages — counts under one default scope: documentation, test, and generated files are excluded from the code count.
The exclusion is directory-based. Alongside the always-ignored build/VCS directories (node_modules, target, dist, build, vendor, …), the default scope drops these directories wherever they appear in the tree:
Excluded | Directories |
Docs |
|
Tests |
|
Generated |
|
Know the boundaries of the rule:
It is a scope, not a purity claim. Files that happen to live outside those directories still count — a root
README.md, JSON lockfiles, and Rust#[cfg(test)]modules inline in source files are all included.Opt back in explicitly. The web app's analysis options (and the API's
includeDocs/includeTests/includeGeneratedtoggles) count the whole repository when enabled; such runs produce a different measurement of the same repo and are pinned as their own saved results.Reports state their scope. Every report page names its counting scope next to the headline numbers, and the counting-policy section spells out the full effective rules for that specific run.
A 10-repository study of how this filtering moves SLOC counts is on the research page.
Stack
Layer | Tech |
Backend | Rust · Axum · Tokio · SQLx · Postgres · tokei |
Frontend | React · TypeScript · Vite · TanStack Query |
Infra | Cloudflare Pages (Pages Functions SSR) · GHCR image + sloc-infra dual VPS (VPS-A/VPS-B) + Cloudflare Tunnel · Postgres on VPS-B (nightly backups to VPS-A) · Docker Compose (local dev only) |
Badges
Drop a live SLOC badge into any README:
<!-- Default branch — full SLOC summary -->
[](https://octocounts.com/github/:owner/:repo)
<!-- Specific branch -->
[](https://octocounts.com/github/:owner/:repo/tree/:branch)
<!-- Specific tag (pinned to that tag) -->
[](https://octocounts.com/github/:owner/:repo/tree/:tag)
<!-- Specific commit SHA (pinned to that commit) -->
[](https://octocounts.com/github/:owner/:repo/commit/:sha)Add ?lang=<language> to any of the above to get a per-language badge instead:
<!-- Lines of code for a single language -->
[](https://octocounts.com/github/:owner/:repo)
[](https://octocounts.com/github/:owner/:repo/tree/:branch)Language names are case-insensitive (rust, Rust, and RUST all work). If a language is not found in the report the badge shows —. While a fresh analysis is running the badge shows ··· — most badge CDNs will retry automatically.
Cache behaviour | Header |
Default branch / branch |
|
Tag / commit |
|
API
POST /api/analyze { "repoUrl": "...", "refName": "main" }
GET /api/jobs/:id
GET /api/reports/:id
GET /api/stats
GET /badge/:owner/:repo
GET /badge/:owner/:repo/branch/:branch
GET /badge/:owner/:repo/tag/:tag
GET /badge/:owner/:repo/commit/:shaAll badge routes accept an optional ?lang=<language> query parameter that switches the response from the full SLOC summary badge to a per-language shields.io-style badge.
Running it
See how-to-run-and-deploy.md for local development setup, host-native instructions, GitHub token configuration, and production deployment.
Growth report inventory
Popular public repositories are listed in data/popular-repos.txt. The scheduled workflow seed-popular-repos.yml refreshes that curated inventory weekly.
refresh-github-trending.yml discovers GitHub's daily Trending repositories, validates and publishes the current snapshot to /trending, and pre-generates their stable /github/:owner/:repo SLOC reports. Trending provenance stays separate from real /popular access counts; no date-stamped archive pages are generated.
License
Available Tools
2 toolsanalyze_repoB
Analyze a public GitHub repository with OctoCounts and return SLOC totals.
Inputs: repo_url (required), ref.
compare_reposB
Compare SLOC totals between two public GitHub repositories or refs.
Inputs: left_repo_url (required), right_repo_url (required), left_ref, right_ref.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
analyze_repo targets a single repository, while compare_repos targets two repositories or refs. Their boundaries are clear and non-overlapping, so an agent can easily choose the right tool.
Both tools follow a consistent verb_noun pattern: analyze_repo and compare_repos. Naming is predictable and uses snake_case throughout.
Two tools is thin for most MCP servers, though this server has a narrow SLOC-counting purpose. The pair covers single-repo analysis and comparison, but feels minimal.
The core domain of SLOC totals and comparisons is covered by the two tools. Minor gaps exist around deeper breakdowns or output options, but agents can accomplish the primary workflows.
Maintenance
Related MCP Connectors
GitHub MCP — wraps the GitHub public REST API (no auth required for public endpoints)
GitHub repo search, stats, language breakdown and comparison as agent tools.
GitHub Private MCP Pack — access private repos, org data via OAuth. Complements the existing…
Revternal MCP — wraps Revternal's people/developer intelligence API (api.revternal.com), rebuilt…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides four GitHub superpowers (repo-scorecard, compare-repos, commit-heatmap, trending-mcp) as MCP tools with React widgets for repository health analysis, comparison, commit activity visualization, and trending MCP servers.475 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables GitHub repository analysis including health score, comparison, commit heatmap, and trending MCP servers, with interactive widgets.475 npmMIT
- FlicenseNot gradedqualityCmaintenanceEnables read-only browsing and querying of GitHub repositories, including listing repos, reading files, fetching READMEs, searching code, and viewing commit history via MCP.-
- AlicenseNot gradedqualityCmaintenanceLets MCP-compatible clients answer natural-language questions about your GitHub activity, such as counting today's commits across all your repositories via the GitHub REST API.475 npm1MIT