Skip to content

tenets.mcp Package

Tenets MCP Server - Model Context Protocol integration.

This module provides an MCP server that exposes tenets functionality to AI coding assistants like Cursor, Claude Desktop, Windsurf, and custom agents.

The MCP server wraps the existing tenets core library, providing: - Tools: Actions AI can invoke (distill, rank, examine, etc.) - Resources: Data AI can read (context history, session state, analysis) - Prompts: Reusable interaction templates

Usage

Start the MCP server (stdio transport for local IDE integration)

$ tenets-mcp

Or with specific transport

$ tenets-mcp --transport stdio # Local (default) $ tenets-mcp --transport sse # Server-Sent Events $ tenets-mcp --transport http # Streamable HTTP

Programmatic usage

from tenets.mcp import create_server server = create_server() server.run(transport="stdio")

Configuration

MCP settings can be configured in .tenets.yml:

YAML
mcp:
  enabled: true
  transports:
    stdio: true
    sse: false
    http: false

Example IDE Configuration (Claude Desktop):

JSON
{
  "mcpServers": {
    "tenets": {
      "command": "tenets-mcp",
      "args": []
    }
  }
}

Classes

TenetsMCP

Python
TenetsMCP(name: str = 'tenets', config: Optional[TenetsConfig] = None, project_path: Optional[Path] = None)

Tenets MCP Server.

Wraps the tenets core library and exposes functionality via MCP protocol. This class manages the FastMCP server instance and handles lifecycle.

ATTRIBUTEDESCRIPTION
name

Server name for MCP identification.

tenets

Underlying Tenets instance for actual functionality.

TYPE:Tenets

config

Configuration for the MCP server.

TYPE:Tenets

Example

from tenets.mcp import TenetsMCP server = TenetsMCP() server.run(transport="stdio")

Initialize the MCP server.

PARAMETERDESCRIPTION
name

Server name shown to MCP clients.

TYPE:strDEFAULT:'tenets'

config

Optional TenetsConfig. If not provided, uses defaults.

TYPE:Optional[TenetsConfig]DEFAULT:None

project_path

Optional project root path. Defaults to cwd.

TYPE:Optional[Path]DEFAULT:None

Attributes

nameinstance-attribute
Python
name = name
tenetsproperty
Python
tenets: Tenets

Lazy-load the Tenets instance.

Functions

run
Python
run(transport: Literal['stdio', 'sse', 'http'] = 'stdio', host: str = '127.0.0.1', port: int = 8080) -> None

Run the MCP server with the specified transport.

PARAMETERDESCRIPTION
transport

Transport type - stdio (local), sse, or http (remote).

TYPE:Literal['stdio', 'sse', 'http']DEFAULT:'stdio'

host

Host for network transports (sse, http).

TYPE:strDEFAULT:'127.0.0.1'

port

Port for network transports (sse, http).

TYPE:intDEFAULT:8080

Functions

create_server

Python
create_server(name: str = 'tenets', config: Optional[TenetsConfig] = None) -> TenetsMCP

Create a new Tenets MCP server instance.

Factory function for creating MCP servers. This is the recommended way to instantiate the server for programmatic use.

PARAMETERDESCRIPTION
name

Server name shown to MCP clients.

TYPE:strDEFAULT:'tenets'

config

Optional TenetsConfig for customization.

TYPE:Optional[TenetsConfig]DEFAULT:None

RETURNSDESCRIPTION
TenetsMCP

Configured TenetsMCP instance ready to run.

Example

from tenets.mcp import create_server server = create_server() server.run(transport="stdio")

main

Python
main() -> None

CLI entry point for tenets-mcp server.

Parses command-line arguments and starts the MCP server with the specified transport configuration.

Modules