Agent Context Token Optimizer MCP Server
Provides task-context handoff for history compression and tool wrapper for secure vault in CrewAI.
Offers history compression helper and owner-bound secure tool-output vault for Hermes Agent.
Supports duck-typed conversion and state helper for history compression, plus core helper composable in a tool wrapper for vault in LangChain.
Supports duck-typed conversion and state helper for history compression, plus core helper composable in a tool wrapper for vault in LangGraph.
Provides Python message helper for history compression and explicit middleware helper for secure tool-output vault with OpenAI-compatible APIs.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Agent Context Token Optimizer MCP Serverstore the result of my last analysis under 'analysis_v1'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Agent Context Token Optimizer v2
English
A local-first, dependency-free core for replacement-history compaction and an owner-bound secure tool-output vault, with honest adapters for multiple agent ecosystems.
Capability matrix
Target | History | Vault | Mode / boundary |
Hermes Agent | policy helper / explicit host patch point | automatic allowlisted transform hook + retrieval tool | History: integration helper; Vault: Native plugin |
OpenAI-compatible/custom | Python message helper | explicit middleware helper | Native helper when the application controls messages/tool results |
LangChain / LangGraph | duck-typed conversion + state helper | compose the core helper in a tool wrapper | Native helper; this package does not patch framework internals |
AutoGen | message-list helper | compose a tool wrapper | Native helper only at application-owned hooks |
CrewAI | task-context handoff | compose a tool wrapper | Wrapper; no claim of private transcript mutation |
Claude Code | new/resumed-session JSON handoff | explicit MCP tools | Wrapper + MCP-only; cannot rewrite existing history or automatically intercept output |
Codex CLI | new/resumed-session JSON handoff | explicit MCP tools | Wrapper + MCP-only; cannot rewrite existing history or automatically intercept output |
OpenCode | new/resumed-session JSON handoff | explicit MCP tools | Wrapper + MCP-only; cannot rewrite existing history or automatically intercept output |
MCP caveat: text passed explicitly to store_tool_result normally already entered the host/model context. MCP provides owner-bound retention and retrieval, not retroactive token savings or automatic interception.
Install and run
python3 -m pip install .
context-token-optimizer install-hermes-plugin
python3 -m token_optimizer.cli compact --agent claude-code < handoff.json
TOKEN_OPTIMIZER_OWNER='<host-generated-opaque-id>' \
python3 -m token_optimizer.mcp_server --store ~/.context-token-optimizer/vault
python3 -m pytest -qNever let the model choose the MCP process owner. Generate/bind it in host configuration. See Integration, Architecture, Verification, and Changelog.
Safety contract
Latest real user intent remains last; summaries are reference-only. Vault artifacts use hashed owner binding, strict IDs/types, sensitive-content rejection, SHA-256 integrity, 0700 directories, 0600 files, atomic writes, TTL checks on read and cleanup, and a total quota. These controls reduce risk but do not make retained untrusted content safe to execute.
Related MCP server: Cortex MCP Server
中文
v2 提供本地优先、无第三方运行时依赖的替换历史压缩核心和绑定 owner 的安全工具输出仓库,并为多种 Agent 生态提供不夸大能力的适配器。
能力矩阵
目标 | 历史压缩 | 输出仓库 | 模式 / 边界 |
Hermes Agent | 策略 helper / 显式宿主补丁点 | 白名单自动 transform hook + 取回工具 | 历史:集成 helper;Vault:Native 插件 |
OpenAI-compatible/custom | Python 消息 helper | 显式 middleware helper | 应用控制消息和工具结果时为 Native helper |
LangChain / LangGraph | 鸭子类型转换 + state helper | 在工具 wrapper 中组合 core | Native helper;不修改框架内部 |
AutoGen | 消息列表 helper | 组合工具 wrapper | 仅限应用可控 hook 的 Native helper |
CrewAI | task-context handoff | 组合工具 wrapper | Wrapper;不声称修改私有历史 |
Claude Code | 新建/恢复会话 JSON 交接 | 显式 MCP 工具 | Wrapper + MCP-only;不能原地改历史或自动截获输出 |
Codex CLI | 新建/恢复会话 JSON 交接 | 显式 MCP 工具 | Wrapper + MCP-only;不能原地改历史或自动截获输出 |
OpenCode | 新建/恢复会话 JSON 交接 | 显式 MCP 工具 | Wrapper + MCP-only;不能原地改历史或自动截获输出 |
**MCP 限制:**显式传给 store_tool_result 的正文通常已经进入宿主/模型上下文。MCP 只提供绑定 owner 的保存和取回,不代表自动拦截或追溯性节省 Token。
安装与命令同上。MCP owner 必须由宿主生成并通过进程参数/环境绑定,不能让模型传入。安全措施包括 owner 哈希绑定、严格类型与 ID、敏感内容拒绝、SHA-256、原子写、0700/0600 权限、读取时 TTL 和总配额;仓库内容仍应视为不可信数据。
License / 许可证
MIT; third-party projects retain their licenses and copyrights. / MIT;第三方项目保留其许可证与版权。
Available Tools
2 toolsread_omitted_contentC
Read one bounded page from this process owner's local vault.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No | ||
| content_id | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose behavioral traits, but it only states 'read' which implies non-destructive. It fails to mention authentication, error handling, or what happens if content_id is invalid.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is brief (one sentence) which is concise, but it lacks necessary detail, especially regarding parameters and behavior.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (pagination, no output schema, no annotations), the description is incomplete. It does not specify the return format, how to paginate, or what constitutes a 'page'.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, yet the description does not describe any of the three parameters (limit, offset, content_id). The phrase 'bounded page' hints at pagination but does not explain the parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Read') and the resource ('one bounded page from this process owner's local vault'), distinguishing it from the sibling tool 'store_tool_result' which handles writing.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives. The description does not mention the sibling tool or provide any context about prerequisites or scenarios.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
store_tool_resultB
Explicitly store non-sensitive text in this process owner's local vault. Supplied text may already count toward host context.
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| tool_name | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It mentions storing 'non-sensitive' text and a vague side effect about 'host context', but does not disclose persistence behavior, overwrite semantics, error conditions, or any required permissions.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with the primary action. Every word serves a purpose; no redundancy. Efficient and to the point.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simplicity of the tool (2 required parameters, no output schema), the description covers basic purpose. However, it omits important context: what constitutes 'non-sensitive', what 'local vault' implies, whether it overwrites, and what the sibling tool does. Adequate but with gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description adds minimal value. It explains 'content' only as text (implied by 'non-sensitive text'), and does not clarify the purpose of 'tool_name' parameter at all. This leaves the agent guessing about tool invocation details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'store' and resource 'non-sensitive text in this process owner's local vault'. It also hints at a nuance about host context. It is distinct from sibling 'read_omitted_content', which reads rather than stores.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool versus alternatives. While there is only one sibling, the description does not provide context on when storing is appropriate or when to prefer another tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
2 tool updates
v2.0.0- First observed
read_omitted_content - First observed
store_tool_result
TDQS
The two tools have clearly distinct purposes: one stores text, the other reads a stored page. No overlap.
Both tool names follow a consistent verb_noun pattern: store_tool_result and read_omitted_content.
With only 2 tools, the server feels minimal but could be acceptable for a narrowly focused functionality. It is borderline.
Missing essential operations like deleting, updating, or listing stored content, which are needed for full lifecycle management.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Persistent memory for AI agents with OAuth-backed hosted MCP access.
- JustOnceOAuthai.justonce
Persistent memory for AI assistants — one shared, OAuth-secured vault for every MCP client.
- mcpOAuthai.butlerbrain
Persistent memory for AI assistants. Save once; recall from Claude, ChatGPT, or any MCP client.
Related MCP Servers
AlicenseAqualityCmaintenanceEnables AI memory persistence and secure credential management via vault tools for MCP-compatible clients like Claude Desktop, Cursor, and VS Code.1227MIT- AlicenseNot gradedqualityCmaintenanceProvides persistent memory and task management for coding agents via MCP tools, enabling mid-session recall and capture of durable knowledge.1373MIT
- AlicenseNot gradedqualityBmaintenanceProvides a persistent, cross-tool memory layer for AI coding agents via MCP, enabling storage and retrieval of decisions, preferences, and context across different tools and models.61MIT
- AlicenseNot gradedqualityAmaintenanceProvides shared long-term memory for AI coding agents via MCP, allowing tools like Claude Code and Codex to store and retrieve distilled facts, notes, and conversation history to persist context across sessions.114MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DeathOVOGod/agent-context-token-optimizer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server