Labsco
jddunn logo

Tenets

β˜… 8

from jddunn

Offline MCP server that ranks & summarizes code using BM25, TF-IDF, embeddings & git signals; integrates with Cursor, Claude Desktop and Windsurf; privacy preserving.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

tenets

<a href="https://tenets.dev"><img src="https://raw.githubusercontent.com/jddunn/tenets/master/docs/logos/tenets_dark_icon_transparent.png" alt="tenets logo" width="140" /></a>

MCP server for context that feeds your prompts.

Intelligent code context aggregation + automatic guiding principles injectionβ€”100% local.

License: MIT Python 3.9+ PyPI version MCP Server CI codecov Documentation

Coverage note: Measures core modules (distiller, ranking, MCP, CLI, models). Optional features (viz, language analyzers) are excluded.

tenets is an MCP server for AI coding assistants. It solves two critical problems:

  1. Intelligent Code Context β€” Finds, ranks, and aggregates the most relevant code using NLP (BM25, TF-IDF, import centrality, git signals). No more manual file hunting.

  2. Automatic Guiding Principles β€” Injects your tenets (coding standards, architecture rules, security requirements) into every prompt automatically. Prevents context drift in long conversations.

Integrates natively with Cursor, Claude Desktop, Windsurf, VS Code via Model Context Protocol. Also ships a CLI and Python library. 100% local processing β€” no API costs, no data leaving your machine.

What is tenets?

  • Finds all relevant files automatically using NLP analysis
  • Ranks them by importance using BM25, TF-IDF, ML embeddings, and git signals
  • Aggregates them within your token budget with intelligent summarizing
  • Injects guiding principles (tenets) automatically into every prompt for consistency
  • Integrates natively with AI assistants via Model Context Protocol (MCP)
  • Pins critical files per session for guaranteed inclusion
  • Transforms content on demand (strip comments, condense whitespace, or force full raw context)

MCP Tool Surface (AI assistants)

  • Start the MCP server
    Copy & paste β€” that's it
    pip install tenets[mcp]
    tenets-mcp
  • Cursor (~/.cursor/mcp.json)
    Copy & paste β€” that's it
    {
      "mcpServers": {
        "tenets": { "command": "tenets-mcp" }
      }
    }
  • Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json)
    Copy & paste β€” that's it
    {
      "mcpServers": {
        "tenets": { "command": "tenets-mcp" }
      }
    }
  • Tools exposed: distill, rank, examine, session_*, tenet_*, plus search_tools + get_tool_schema for on-demand discovery.
  • Docs: see docs/MCP.md for full endpoint/tool list, SSE/HTTP details, and IDE notes.

MCP Server (AI assistant integration)

Once you start tenets-mcp and drop one of the configs above into your IDE, ask your AI:

  • β€œUse tenets to find the auth code” (calls distill)
  • β€œPin src/auth to session auth-feature” (calls session_pin_folder)
  • β€œRank files for the payment bug” (calls rank_files)

See MCP docs for transports (stdio/SSE/HTTP), tool schemas, and full examples.

How It Works

Code analysis intelligence

tenets employs a multi-layered approach optimized specifically for code understanding (but its core functionality could be applied to any field of document matching). It tokenizes camelCase and snake_case identifiers intelligently. Test files are excluded by default unless specifically mentioned in some way. Language-specific AST parsing for 15+ languages is included.

Multi-ranking NLP

Deterministic algorithms in balanced work reliably and quickly meant to be used by default. BM25 scoring prevents biasing of files which may use redundant patterns (test files with which might have "response" referenced over and over won't necessarily dominate searches for "response").

The default ranking factors consist of: BM25 scoring (25% - statistical relevance preventing repetition bias), keyword matching (20% - direct substring matching), path relevance (15%), TF-IDF similarity (10%), import centrality (10%), git signals (10% - recency 5%, frequency 5%), complexity relevance (5%), and type relevance (5%).

Smart Summarization

When files exceed token budgets, tenets intelligently preserves:

  • Function/class signatures
  • Import statements
  • Complex logic blocks
  • Documentation and comments
  • Recent changes

ML / deep learning embeddings

Semantic understand can be had with ML features: pip install tenets[ml]. Enable with --ml --reranker flags or set use_ml: true and use_reranker: true in config.

In thorough mode, sentence-transformer embeddings are enabled, and understand that authenticate() and login() are conceptually related for example, and that payment even has some crossover in relevancy (since these are typically associated together).

Optional cross-encoder neural re-ranking in this mode jointly evaluates query-document pairs with self-attention for superior accuracy.

A cross-encoder, for example, will correctly rank "DEPRECATED: We no longer implement oauth2" lower than implement_authorization_flow() for query "implement oauth2", understanding the negative context despite keyword matches.

Since cross-encoders process document-query pairs together (O(nΒ²) complexity), they're much slower than bi-encoders and only used for re-ranking top K results.

Documentation

Output Formats

Copy & paste β€” that's it
# Markdown (default, optimized for AI)
tenets distill "implement OAuth2" --format markdown

# Interactive HTML with search, charts, copy buttons
tenets distill "review API" --format html -o report.html

# JSON for programmatic use
tenets distill "analyze" --format json | jq '.files[0]'

# XML optimized for Claude
tenets distill "debug issue" --format xml

Python API

Copy & paste β€” that's it
from tenets import Tenets

# Initialize
tenets = Tenets()

# Basic usage
result = tenets.distill("implement user authentication")
print(f"Generated {result.token_count} tokens")

# Rank files without content
from tenets.core.ranking import RelevanceRanker
ranker = RelevanceRanker(algorithm="balanced")
ranked_files = ranker.rank(files, prompt_context, threshold=0.1)

for file in ranked_files[:10]:
    print(f"{file.path}: {file.relevance_score:.3f}")

Supported Languages

Specialized analyzers for Python, JavaScript/TypeScript, Go, Java, C/C++, Ruby, PHP, Rust, and more. Configuration and documentation files are analyzed with smart heuristics for YAML, TOML, JSON, Markdown, etc.

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.


Documentation Β· MCP Guide Β· Privacy Β· Terms

team@tenets.dev // team@manic.agency