Skip to content

feat(mcp): add live analytics tools backed by shared loaders#2046

Closed
bohdansolovie wants to merge 1 commit into
JSONbored:mainfrom
bohdansolovie:feat/mcp-live-analytics-tools
Closed

feat(mcp): add live analytics tools backed by shared loaders#2046
bohdansolovie wants to merge 1 commit into
JSONbored:mainfrom
bohdansolovie:feat/mcp-live-analytics-tools

Conversation

@bohdansolovie

@bohdansolovie bohdansolovie commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds src/analytics-live.mjs with shared live analytics loaders (loadSubnetUptime, loadRegistryLeaderboards, loadCompareSubnets, loadGlobalIncidents) for MCP tools.
  • Adds four MCP tools mirroring REST analytics endpoints:
    • get_subnet_uptime/api/v1/subnets/{netuid}/uptime
    • get_registry_leaderboards/api/v1/registry/leaderboards
    • compare_subnets/api/v1/compare
    • get_global_incidents/api/v1/incidents
  • Reuses composeCompareData from workers/request-handlers/analytics-routes.mjs (refactor(api): extract deferred analytics routes from api.mjs #1919) — no api.mjs handler reversion, no logic duplication.

Closes #1958

Resubmission of #1960: single commit by bohdansolovie, rebased on latest main after #1919 landed.

Test plan

  • npm test -- tests/analytics-live.test.mjs tests/compare.test.mjs tests/mcp-server.test.mjs
  • npm run lint
  • npm run build (derived artifacts fresh)

@bohdansolovie bohdansolovie requested a review from JSONbored as a code owner June 26, 2026 23:12
@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.25197% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.12%. Comparing base (796da14) to head (9529df4).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/analytics-live.mjs 87.23% 1 Missing and 11 partials ⚠️
src/mcp-server.mjs 75.75% 0 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2046      +/-   ##
==========================================
- Coverage   93.26%   93.12%   -0.15%     
==========================================
  Files          48       49       +1     
  Lines        7755     7878     +123     
  Branches     2839     2899      +60     
==========================================
+ Hits         7233     7336     +103     
- Misses         92       94       +2     
- Partials      430      448      +18     
Files with missing lines Coverage Δ
src/mcp-server.mjs 87.80% <75.75%> (-0.71%) ⬇️
src/analytics-live.mjs 87.23% <87.23%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bohdansolovie bohdansolovie force-pushed the feat/mcp-live-analytics-tools branch 2 times, most recently from c262e23 to 7c8d88c Compare June 26, 2026 23:25
Expose get_subnet_uptime, get_registry_leaderboards, compare_subnets,
and get_global_incidents as MCP tools, backed by src/analytics-live.mjs
loaders shared with the REST analytics routes. Closes JSONbored#1958.
@bohdansolovie bohdansolovie force-pushed the feat/mcp-live-analytics-tools branch from 7c8d88c to 9529df4 Compare June 26, 2026 23:31
@JSONbored JSONbored added the gittensor:feature Feature / enhancement label Jun 27, 2026

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #1958 (open, wanted). Four new MCP tools (get_subnet_uptime, get_registry_leaderboards, compare_subnets, get_global_incidents) backed by src/analytics-live.mjs. The new loaders are correct extractions of the REST-layer logic; the MCP tool definitions in src/mcp-server.mjs are well-formed. Substantively good.

Same block as #2032: the diff includes public/.well-known/mcp/server-card.json (committed under the old workflow) and also public/metagraph/operational-surfaces.json + public/metagraph/r2-manifest.json (generated build artifacts that should never be committed). #2055 deleted the server-card from git, causing a conflict. Closing. Resubmit with three files dropped from the diff entirely: public/.well-known/mcp/server-card.json, public/metagraph/operational-surfaces.json, public/metagraph/r2-manifest.json. The analytics-live module and the MCP tool additions are clean — I'll take them on a fresh branch.

@JSONbored JSONbored closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Feature / enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): add live analytics tools for leaderboards, compare, uptime, and incidents

2 participants