Skip to content

feat(mcp): wire MCP tools to real tok package and align docs to library-only#58

Merged
Patel230 merged 1 commit into
mainfrom
feat/mcp-real-impls-and-library-docs
Jun 12, 2026
Merged

feat(mcp): wire MCP tools to real tok package and align docs to library-only#58
Patel230 merged 1 commit into
mainfrom
feat/mcp-real-impls-and-library-docs

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Three changes that together bring tok's MCP surface and its docs in line with the actual library-only codebase.

mcp/server.go

The existing implementation was a stub that hard-coded:

  • count_tokens: len(text)/4 (no BPE)
  • estimate_cost: returns 0.0 (no pricing)
  • compress_text: collapseWS (no pipeline)

Replace each handler with a real call into the public tok API:

  • count_tokens(text, model)tok.EstimateTokens / EstimateTokensForModel
  • estimate_cost(model, in, out)tok.GetModelPricing × (in/1000*ip + out/1000*op)
  • compress_text(text, mode, budget?)tok.Compress with preset Option
  • redact_secrets(text, entropy?)tok.NewSecretDetector (new tool)

The legacy collapseWS helper is removed.

mcp/server_test.go

Replace the stub tests with real-pipeline tests. The 4× token reduction assertion on aggressive mode is the stub-regression guard: a future refactor that re-introduces len/4 / 0.0 / collapseWS shortcuts fails CI. 10 new tests added.

ARCHITECTURE.md

Still claimed 'Go library and CLI tool' and drew a Tok CLI box with command runner / filter selector / rewrite engine. Also referenced agents/ and hooks/ directories that don't exist, and a 'Command Rewriting' flow that was never library-side.

Rewrite to library-only architecture, drop the CLI box and the Command Rewriting section, update the file structure table to match reality, update Security to 33 patterns, update Build & Release to library distribution via go get.

CITATION.cff

Title and abstract claimed 'Token-Aware CLI Proxy'. Update to 'A Go Library for Prompt Compression, Output Filtering, Token Estimation, and Secret Detection' and reword the abstract to describe the library API, the 31-layer pipeline, and the go-get distribution path.

Verification

  • go build ./...
  • go test ./mcp/ -race -count=1 ✓ 16/16 pass
  • go test . (main package smoke) ✓
  • gofumpt -l mcp/ / goimports -l mcp/ ✓ clean

…ry-only

Three changes that together bring tok's MCP surface and its docs
in line with the actual library-only codebase.

mcp/server.go — the existing implementation was a stub that
hard-coded:
  - count_tokens:   len(text)/4  (no BPE)
  - estimate_cost:  return 0.0  (no pricing)
  - compress_text:  collapseWS   (no pipeline)
Replace each handler with a real call into the public tok API:
  - count_tokens(text, model)   → tok.EstimateTokens / EstimateTokensForModel
  - estimate_cost(model, in, out) → tok.GetModelPricing × (in/1000*ip + out/1000*op)
  - compress_text(text, mode, budget?) → tok.Compress with preset Option
  - redact_secrets(text, entropy?) → tok.NewSecretDetector (new tool)
Add a 4th tool redact_secrets backed by the 33-pattern secret
detector. The legacy collapseWS helper is removed.

mcp/server_test.go — replace the stub tests with real-pipeline
tests. The 4x token reduction assertion on aggressive mode is the
stub-regression guard: a future refactor that re-introduces
len/4 / 0.0 / collapseWS shortcuts fails CI.

ARCHITECTURE.md — still claimed 'Go library and CLI tool' and
drew a Tok CLI box with command runner / filter selector / rewrite
engine. Also referenced agents/ and hooks/ directories that don't
exist, and a 'Command Rewriting' flow that was never library-side.
Rewrite to library-only architecture, drop the CLI box and the
Command Rewriting section, update the file structure table to
match reality, update Security to 33 patterns, update Build &
Release to library distribution via 'go get'.

CITATION.cff — title and abstract claimed 'Token-Aware CLI Proxy'.
Update to 'A Go Library for Prompt Compression, Output Filtering,
Token Estimation, and Secret Detection' and reword the abstract
to describe the library API, the 31-layer pipeline, and the
go-get distribution path.
@Patel230 Patel230 merged commit 5df7ee7 into main Jun 12, 2026
20 checks passed
@Patel230 Patel230 deleted the feat/mcp-real-impls-and-library-docs branch June 12, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant