upfront 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. upfront-0.1.0/.editorconfig +12 -0
  2. upfront-0.1.0/.github/ISSUE_TEMPLATE/bug.yml +16 -0
  3. upfront-0.1.0/.github/ISSUE_TEMPLATE/feature.yml +14 -0
  4. upfront-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +9 -0
  5. upfront-0.1.0/.github/dependabot.yml +10 -0
  6. upfront-0.1.0/.github/workflows/ci.yml +66 -0
  7. upfront-0.1.0/.github/workflows/release.yml +59 -0
  8. upfront-0.1.0/.gitignore +14 -0
  9. upfront-0.1.0/.pre-commit-config.yaml +21 -0
  10. upfront-0.1.0/.python-version +1 -0
  11. upfront-0.1.0/CHANGELOG.md +31 -0
  12. upfront-0.1.0/CODE_OF_CONDUCT.md +83 -0
  13. upfront-0.1.0/CONTRIBUTING.md +40 -0
  14. upfront-0.1.0/LICENSE +21 -0
  15. upfront-0.1.0/MISSION.md +91 -0
  16. upfront-0.1.0/PKG-INFO +146 -0
  17. upfront-0.1.0/README.md +121 -0
  18. upfront-0.1.0/SECURITY.md +28 -0
  19. upfront-0.1.0/docs/api.md +121 -0
  20. upfront-0.1.0/docs/concepts.md +52 -0
  21. upfront-0.1.0/docs/decisions/ADR-0001-name.md +21 -0
  22. upfront-0.1.0/docs/decisions/ADR-0002-python-and-no-llm-calls.md +18 -0
  23. upfront-0.1.0/docs/decisions/ADR-0003-tokenizer.md +17 -0
  24. upfront-0.1.0/docs/decisions/ADR-0004-consent-before-launching.md +16 -0
  25. upfront-0.1.0/docs/decisions/ADR-0005-house-style-deviations.md +15 -0
  26. upfront-0.1.0/docs/demo.gif +0 -0
  27. upfront-0.1.0/docs/demo.tape +28 -0
  28. upfront-0.1.0/docs/faq.md +55 -0
  29. upfront-0.1.0/docs/quickstart.md +46 -0
  30. upfront-0.1.0/examples/claude_code_18260_ref_params.py +20 -0
  31. upfront-0.1.0/examples/codex_19679_skills_budget.py +32 -0
  32. upfront-0.1.0/examples/demo/.agents/skills/release/SKILL.md +10 -0
  33. upfront-0.1.0/examples/demo/.agents/skills/review/SKILL.md +10 -0
  34. upfront-0.1.0/examples/demo/.claude/skills/release/SKILL.md +10 -0
  35. upfront-0.1.0/examples/demo/.claude/skills/review/SKILL.md +10 -0
  36. upfront-0.1.0/examples/demo/.codex/config.toml +7 -0
  37. upfront-0.1.0/examples/demo/.mcp.json +7 -0
  38. upfront-0.1.0/examples/demo/AGENTS.md +5 -0
  39. upfront-0.1.0/examples/demo/CLAUDE.md +5 -0
  40. upfront-0.1.0/examples/opencode_11995_tool_descriptions.py +29 -0
  41. upfront-0.1.0/examples/servers/everything.tools.json +394 -0
  42. upfront-0.1.0/examples/servers/filesystem.tools.json +666 -0
  43. upfront-0.1.0/examples/servers/issue-scenarios.tools.json +32 -0
  44. upfront-0.1.0/examples/servers/memory.tools.json +713 -0
  45. upfront-0.1.0/examples/servers/replay_server.py +64 -0
  46. upfront-0.1.0/pyproject.toml +68 -0
  47. upfront-0.1.0/scripts/gen_api_docs.py +91 -0
  48. upfront-0.1.0/src/upfront/__init__.py +7 -0
  49. upfront-0.1.0/src/upfront/cli.py +147 -0
  50. upfront-0.1.0/src/upfront/compat.py +227 -0
  51. upfront-0.1.0/src/upfront/discover.py +439 -0
  52. upfront-0.1.0/src/upfront/fetch.py +132 -0
  53. upfront-0.1.0/src/upfront/py.typed +0 -0
  54. upfront-0.1.0/src/upfront/report.py +157 -0
  55. upfront-0.1.0/src/upfront/tokens.py +50 -0
  56. upfront-0.1.0/tests/__init__.py +0 -0
  57. upfront-0.1.0/tests/conftest.py +112 -0
  58. upfront-0.1.0/tests/test_cli.py +78 -0
  59. upfront-0.1.0/tests/test_compat.py +78 -0
  60. upfront-0.1.0/tests/test_discover.py +87 -0
  61. upfront-0.1.0/tests/test_examples.py +28 -0
  62. upfront-0.1.0/tests/test_fetch.py +123 -0
  63. upfront-0.1.0/tests/test_tokens.py +58 -0
  64. upfront-0.1.0/uv.lock +1935 -0
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ trim_trailing_whitespace = true
8
+ indent_style = space
9
+ indent_size = 4
10
+
11
+ [*.{yml,yaml,json,toml,md}]
12
+ indent_size = 2
@@ -0,0 +1,16 @@
1
+ name: Bug report
2
+ description: Something doesn't work as documented
3
+ labels: [bug]
4
+ body:
5
+ - type: textarea
6
+ id: what
7
+ attributes: {label: What happened, description: Command you ran and the output}
8
+ validations: {required: true}
9
+ - type: textarea
10
+ id: expected
11
+ attributes: {label: What you expected}
12
+ validations: {required: true}
13
+ - type: input
14
+ id: version
15
+ attributes: {label: Version, description: "`upfront --version`, OS, Python version"}
16
+ validations: {required: true}
@@ -0,0 +1,14 @@
1
+ name: Feature request
2
+ description: Suggest an idea
3
+ labels: [enhancement]
4
+ body:
5
+ - type: textarea
6
+ id: problem
7
+ attributes: {label: The problem, description: "What are you trying to do, and what gets in the way?"}
8
+ validations: {required: true}
9
+ - type: textarea
10
+ id: proposal
11
+ attributes: {label: Proposed solution}
12
+ - type: textarea
13
+ id: links
14
+ attributes: {label: Related issues or threads elsewhere}
@@ -0,0 +1,9 @@
1
+ ## What and why
2
+
3
+ ## How tested
4
+ - [ ] `pre-commit run --all-files`
5
+ - [ ] `uv run pytest --cov`
6
+
7
+ ## Checklist
8
+ - [ ] CHANGELOG.md updated under `[Unreleased]`
9
+ - [ ] Docs updated if behaviour changed
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: /
5
+ schedule: {interval: weekly}
6
+ groups: {actions: {patterns: ["*"]}}
7
+ - package-ecosystem: uv
8
+ directory: /
9
+ schedule: {interval: weekly}
10
+ groups: {python: {patterns: ["*"]}}
@@ -0,0 +1,66 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ lint:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
16
+ with:
17
+ persist-credentials: false
18
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
19
+ - run: uv sync --locked --all-extras --dev
20
+ - run: uv run ruff check .
21
+ - run: uv run ruff format --check .
22
+ - run: uv run mypy --strict src
23
+ - run: uv run python scripts/gen_api_docs.py --check
24
+
25
+ test:
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ os: [ubuntu-latest, macos-latest]
30
+ python: ["3.11", "3.12", "3.13"]
31
+ runs-on: ${{ matrix.os }}
32
+ steps:
33
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34
+ with:
35
+ persist-credentials: false
36
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
37
+ with:
38
+ python-version: ${{ matrix.python }}
39
+ - run: uv sync --locked --all-extras --dev
40
+ - run: uv run pytest --cov --cov-report=xml --cov-fail-under=85
41
+ - if: matrix.os == 'ubuntu-latest' && matrix.python == '3.13'
42
+ uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
43
+ with:
44
+ use_oidc: true
45
+ fail_ci_if_error: false
46
+ permissions:
47
+ contents: read
48
+ id-token: write # codecov tokenless upload via OIDC
49
+
50
+ example:
51
+ # Runs the README example as a user would. Replace with the project's real 10-line demo.
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
55
+ with:
56
+ persist-credentials: false
57
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
58
+ - run: uv sync --locked
59
+ - name: README demo output still matches
60
+ run: |
61
+ HOME="$(mktemp -d)" uv run upfront examples/demo --yes --top 2 | tee out.txt
62
+ grep -F "claude-code ≈ 6,786 before your first prompt" out.txt
63
+ grep -F "mcp filesystem (14 tools, project) ≈ 2,751" out.txt
64
+ grep -F "[openai-tool-name]" out.txt
65
+ - name: Examples named after the issues still run
66
+ run: for f in examples/*.py; do uv run python "$f"; done
@@ -0,0 +1,59 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*.*.*"]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
15
+ with:
16
+ persist-credentials: false
17
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
18
+ - name: Tag matches package version
19
+ run: test "${GITHUB_REF_NAME#v}" = "$(uv version --short)"
20
+ - run: uv build
21
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
22
+ with:
23
+ name: dist
24
+ path: dist/
25
+
26
+ pypi:
27
+ needs: build
28
+ runs-on: ubuntu-latest
29
+ environment:
30
+ name: pypi
31
+ url: https://pypi.org/p/upfront
32
+ permissions:
33
+ id-token: write # PyPI trusted publishing
34
+ steps:
35
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
36
+ with:
37
+ name: dist
38
+ path: dist/
39
+ - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
40
+
41
+ github-release:
42
+ needs: pypi
43
+ runs-on: ubuntu-latest
44
+ permissions:
45
+ contents: write
46
+ steps:
47
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
48
+ with:
49
+ persist-credentials: false
50
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
51
+ with:
52
+ name: dist
53
+ path: dist/
54
+ - name: Create release from CHANGELOG section
55
+ env:
56
+ GH_TOKEN: ${{ github.token }}
57
+ run: |
58
+ awk -v v="${GITHUB_REF_NAME#v}" '$0 ~ "^## \\[" v "\\]" {f=1; next} /^## \[/ {f=0} f' CHANGELOG.md > notes.md
59
+ gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --notes-file notes.md
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ htmlcov/
12
+ .env
13
+ .DS_Store
14
+ .tiktoken-cache/
@@ -0,0 +1,21 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.17.0
4
+ hooks:
5
+ - id: ruff-check
6
+ args: [--fix]
7
+ - id: ruff-format
8
+ - repo: local
9
+ hooks:
10
+ - id: mypy
11
+ name: mypy --strict
12
+ entry: uv run mypy --strict src
13
+ language: system
14
+ pass_filenames: false
15
+ types: [python]
16
+ - id: pytest
17
+ name: pytest (pre-push)
18
+ entry: uv run pytest -q -x
19
+ language: system
20
+ pass_filenames: false
21
+ stages: [pre-push]
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-10-13
10
+
11
+ ### Added
12
+
13
+ - `upfront [PATH]`: reports, per coding agent, the estimated tokens loaded before the first
14
+ prompt by MCP tool definitions, skill metadata and instruction files.
15
+ - Config discovery for Claude Code (`.mcp.json`, `~/.claude.json` user and local scope),
16
+ Codex (`.codex/config.toml`, `~/.codex/config.toml`), Gemini CLI (`.gemini/settings.json`)
17
+ and OpenCode (`opencode.json[c]`), with skills folders and AGENTS/CLAUDE/GEMINI.md.
18
+ - `tools/list` over stdio, Streamable HTTP and SSE via the official MCP SDK, with pagination,
19
+ per-server timeouts and per-server errors (including "auth required" and the server's last
20
+ stderr line).
21
+ - Compatibility findings that cite their source: OpenAI, Anthropic and Gemini tool-name rules,
22
+ `$ref` parameters in Claude Code (claude-code#18260), non-standard formats in OpenCode
23
+ (opencode#15161), and Codex's skills-list budget.
24
+ - `--json`, `--budget`, `--strict`, `--tools-file`, `--top`, `--timeout`, `-H/--harness`.
25
+ - Servers are started only with consent (interactive prompt or `--yes`).
26
+ - Library API: `upfront.profile()` and `upfront.profile_tools_file()`.
27
+ - Examples reproducing codex#19679, opencode#11995 and claude-code#18260, and a demo project
28
+ with tools/list snapshots of three official MCP reference servers.
29
+
30
+ [Unreleased]: https://github.com/thanatchon36/upfront/compare/v0.1.0...HEAD
31
+ [0.1.0]: https://github.com/thanatchon36/upfront/releases/tag/v0.1.0
@@ -0,0 +1,83 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
22
+ * Trolling, insulting or derogatory comments, and personal or political attacks
23
+ * Public or private harassment
24
+ * Publishing others' private information, such as a physical or email address, without their explicit permission
25
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Enforcement Responsibilities
28
+
29
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32
+
33
+ ## Scope
34
+
35
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at the maintainer (@thanatchon36) privately, using this repository's "Report a vulnerability" form under the Security tab, which only maintainers can read. All complaints will be reviewed and investigated promptly and fairly.
40
+
41
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42
+
43
+ ## Enforcement Guidelines
44
+
45
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46
+
47
+ ### 1. Correction
48
+
49
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50
+
51
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52
+
53
+ ### 2. Warning
54
+
55
+ **Community Impact**: A violation through a single incident or series of actions.
56
+
57
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58
+
59
+ ### 3. Temporary Ban
60
+
61
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62
+
63
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64
+
65
+ ### 4. Permanent Ban
66
+
67
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68
+
69
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
70
+
71
+ ## Attribution
72
+
73
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74
+
75
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
76
+
77
+ For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
78
+
79
+ [homepage]: https://www.contributor-covenant.org
80
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
81
+ [Mozilla CoC]: https://github.com/mozilla/diversity
82
+ [FAQ]: https://www.contributor-covenant.org/faq
83
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,40 @@
1
+ # Contributing
2
+
3
+ Thanks for helping. Bug reports with a config that reproduces the problem are the most useful
4
+ contribution: say which agent, which config file, and paste the relevant `upfront --json` output.
5
+
6
+ ## Setup
7
+
8
+ You need [uv](https://docs.astral.sh/uv/). Python 3.11+ is installed by uv if missing.
9
+
10
+ ```bash
11
+ git clone https://github.com/thanatchon36/upfront && cd upfront
12
+ uv sync
13
+ uv run pre-commit install
14
+ ```
15
+
16
+ ## Checks (the same ones CI runs)
17
+
18
+ ```bash
19
+ uv run pre-commit run --all-files # ruff check, ruff format, mypy --strict
20
+ uv run pytest --cov --cov-fail-under=85
21
+ ```
22
+
23
+ Tests start real MCP servers from `examples/servers/replay_server.py`, so they need no network
24
+ except the tokenizer download on first run.
25
+
26
+ ## Adding a compatibility rule
27
+
28
+ Rules live in `src/upfront/compat.py`. Every rule must link the public issue or documentation
29
+ it comes from and needs a test with a tool that triggers it and one that doesn't. Rules that
30
+ can't cite a source won't be merged: a false "this breaks in X" is worse than no warning.
31
+
32
+ ## Adding a harness
33
+
34
+ Add a reader in `src/upfront/discover.py`, a fixture config under `tests/fixtures/`, and link
35
+ the harness's documentation for the config format in the reader's docstring.
36
+
37
+ ## Commits and pull requests
38
+
39
+ - Use [Conventional Commits](https://www.conventionalcommits.org/): `feat:`, `fix:`, `docs:`, `test:`, `chore:`.
40
+ - One logical change per pull request, with tests. Add a line under `[Unreleased]` in CHANGELOG.md.
upfront-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thanatchon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,91 @@
1
+ # upfront — Mission
2
+
3
+ > See how many tokens each MCP server, skill and instruction file costs your coding agent before you type a word, and which tools will break in Claude Code, Codex, Gemini CLI or OpenCode.
4
+
5
+ Status: in development (v0.1.0 target)
6
+
7
+ ## Problem
8
+
9
+ Coding agents load a lot before your first prompt: every connected MCP server's tool schemas, the name and description of every installed skill, and every AGENTS.md / CLAUDE.md / GEMINI.md. Users notice it as a usage meter that climbs too fast or tools that silently disappear. The harnesses show little of it: Claude Code has `/context`, but only for itself, and OpenCode declined to build a breakdown. When the same MCP server moves between agents, schemas that work in one client fail in another.
10
+
11
+ - [HN: Claude Code sends 33k tokens before reading the prompt; OpenCode sends 7k](https://news.ycombinator.com/item?id=48883275) — 706 points, 2026-07-12. Users had to put a logging proxy in front of the agent to find out.
12
+ - [openai/codex#19679 — Make skills metadata context budget configurable instead of hardcoded 2%](https://github.com/openai/codex/issues/19679) — 👍40, open. Skill descriptions are shortened or dropped once the list passes 2% of the window, and users can't see when that happens.
13
+ - [openai/codex#44308 — Agent Plugin MCP tools are silently hidden after the global schema budget is exhausted](https://github.com/openai/codex/issues/44308) — 👍6, open.
14
+ - [anomalyco/opencode#11995 — Tool descriptions consume excessive tokens in system prompt](https://github.com/anomalyco/opencode/issues/11995) — 👍17, closed *not planned*.
15
+ - [openai/codex#26234 — Flatten MCP namespace tools for non-OpenAI Responses API providers](https://github.com/openai/codex/issues/26234) — 👍49, open.
16
+ - [anthropics/claude-code#18260 — MCP tool parameters with $ref schemas are incorrectly serialized as string](https://github.com/anthropics/claude-code/issues/18260) — 👍9, open.
17
+
18
+ The full evidence and gap check are in the pain-point report and `decision.md` in the research workspace.
19
+
20
+ ## Target user
21
+
22
+ A developer who uses one or more coding agents (Claude Code, Codex CLI, Gemini CLI, OpenCode) with several MCP servers and skills installed. They hit usage limits sooner than expected, or see tools go missing, and want to know which server or skill to cut. A second user is the **MCP server author** who wants to know what their server costs agents and whether its schemas work in every client, from CI.
23
+
24
+ ## Before / after
25
+
26
+ **Before:** route the agent through a logging proxy (mitmproxy or a custom one), capture the first request, and count tokens by hand. Or install and remove servers one at a time and watch the usage meter. For schema compatibility: connect the server to each agent and wait for a 400.
27
+
28
+ **After** (illustrative; real output is in the README):
29
+ ```console
30
+ $ upfront --yes
31
+ claude-code ≈ 24,180 tokens before your first prompt
32
+ mcp github 41 tools ≈ 18,920
33
+ mcp playwright 21 tools ≈ 3,140
34
+ skills 12 (metadata) ≈ 1,320 (bodies ≈ 21,400, loaded on demand)
35
+ CLAUDE.md ≈ 800
36
+ compat ⚠ gemini-cli github.create_issue uses $ref/$defs (gemini-cli#13326)
37
+ ```
38
+
39
+ ## Non-goals (v0.1)
40
+
41
+ - **Measuring the harness's own system prompt.** It's vendor-internal and changes every release. upfront measures only what *you* add (servers, skills, instruction files).
42
+ - **Exact token counts for every model.** v0.1 uses one tokenizer (`o200k_base`) as a stated estimate. Calling vendor token-count APIs would need keys and network, so it's on the roadmap.
43
+ - **Rewriting schemas (a "fix" proxy).** v0.1 reports problems and doesn't change traffic.
44
+ - **Runtime token usage of conversations.** That's already solved by ccusage, codeburn and others.
45
+ - **OAuth flows for remote servers.** Servers that need auth are reported as "auth required, not measured".
46
+ - **Cursor, Windsurf and other IDE agents.** Four CLI harnesses first.
47
+
48
+ ## Architecture
49
+
50
+ ```text
51
+ configs on disk ──► discover ──► [Server specs, skills, instruction files]
52
+ │
53
+ (consent) ──► fetch ──► tools/list via MCP SDK (stdio / Streamable HTTP)
54
+ │
55
+ ▼
56
+ tokens (o200k_base) + compat rules
57
+ │
58
+ ▼
59
+ Report ──► plain-text table / JSON / exit code
60
+ ```
61
+
62
+ - `upfront/discover.py` — reads Claude Code (`.mcp.json`, `~/.claude.json`), Codex (`.codex/config.toml`, `~/.codex/config.toml`), Gemini CLI (`.gemini/settings.json`, `~/.gemini/settings.json`) and OpenCode (`opencode.json[c]`, `~/.config/opencode/opencode.json`). Also finds skills dirs and instruction files.
63
+ - `upfront/fetch.py` — launches or connects to each server with the official `mcp` SDK, with a per-server timeout, and paginates `tools/list`. Failures are recorded, never raised.
64
+ - `upfront/tokens.py` — counts tokens for each tool's wire JSON (name, description, input/output schema), each skill's metadata and body, and each instruction file. Falls back to a chars/4 estimate if the tokenizer can't load offline.
65
+ - `upfront/compat.py` — static rules, each linked to the public issue it comes from.
66
+ - `upfront/report.py` + `upfront/cli.py` — rendering, JSON, budget exit codes.
67
+
68
+ External deps: `mcp` (official SDK), `tiktoken` (tokenizer), `typer` (CLI). No LLM calls, no API keys.
69
+
70
+ **Safety:** project-level config files can name arbitrary commands, so upfront only launches servers after confirmation (`--yes` for non-interactive use). Without consent it reports static data only.
71
+
72
+ ## MVP features → acceptance tests
73
+
74
+ | # | Feature | Acceptance test | Closes use case in |
75
+ |---|---|---|---|
76
+ | F1 | Discover MCP servers, skills and instruction files for 4 harnesses, project + user scope | `tests/test_discover.py::test_discovers_all_four_harnesses` — a fixture project with all four config formats yields the expected servers, skills and files per harness | HN 33k-tokens thread |
77
+ | F2 | Fetch every tool from stdio and Streamable HTTP servers (paginated, timeout, failures recorded) | `tests/test_fetch.py::test_fetches_paginated_tools_over_stdio_and_http` + `::test_failing_server_is_recorded_not_raised` | codex#44308 |
78
+ | F3 | Count tokens per tool, server, skill (metadata vs body) and instruction file | `tests/test_tokens.py::test_counts_scale_with_schema_and_skill_metadata_is_separate_from_body` | opencode#11995, codex#19679 |
79
+ | F4 | Compatibility rules per client, each linked to its source issue, plus the Codex 2% skills-list budget | `tests/test_compat.py::test_flags_each_known_breaker_and_passes_clean_tools` | codex#26234, claude-code#18260, codex#19679 |
80
+ | F5 | CLI: ranked table, `--json`, `--budget N` exit code, `--tools-file` offline mode, launch only with consent | `tests/test_cli.py::test_budget_exit_code_and_json_and_consent` | CI use for server authors |
81
+
82
+ ## Success metrics
83
+
84
+ - Each cited issue's scenario reproduces as a passing example in `examples/` (yes/no per link): codex#19679, opencode#11995, codex#26234 / claude-code#18260.
85
+ - CI green on Python 3.11–3.13 × Linux/macOS, and coverage ≥ 85%.
86
+ - In 30 days: at least one issue or PR from someone other than the author, and one MCP server repo using `upfront --budget` in CI. Stars don't count as a goal.
87
+
88
+ ## Roadmap
89
+
90
+ - **v0.2** — exact counts via vendor token-count endpoints (opt-in, with key); `--fix` stdio proxy that rewrites schemas per client (inline `$ref`, shorten names), from report theme #1; Cursor/Windsurf configs.
91
+ - **v0.3** — diff mode (`upfront diff main..HEAD` for MCP server PRs); a GitHub Action wrapper; per-model tokenizers.
upfront-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.5
2
+ Name: upfront
3
+ Version: 0.1.0
4
+ Summary: See how many tokens your MCP servers, skills and instruction files cost a coding agent before your first prompt, and which tools break in which client.
5
+ Project-URL: Homepage, https://github.com/thanatchon36/upfront
6
+ Project-URL: Issues, https://github.com/thanatchon36/upfront/issues
7
+ Project-URL: Changelog, https://github.com/thanatchon36/upfront/blob/main/CHANGELOG.md
8
+ Author: Thanatchon
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: claude-code,codex,context-window,gemini-cli,llm,mcp,model-context-protocol,opencode,tokens
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: mcp>=2.3.0
22
+ Requires-Dist: tiktoken>=0.14.0
23
+ Requires-Dist: typer>=0.27.3
24
+ Description-Content-Type: text/markdown
25
+
26
+ # upfront
27
+
28
+ [![ci](https://github.com/thanatchon36/upfront/actions/workflows/ci.yml/badge.svg)](https://github.com/thanatchon36/upfront/actions/workflows/ci.yml)
29
+ [![coverage](https://codecov.io/gh/thanatchon36/upfront/graph/badge.svg)](https://codecov.io/gh/thanatchon36/upfront)
30
+ [![PyPI](https://img.shields.io/pypi/v/upfront)](https://pypi.org/project/upfront/)
31
+ [![Python](https://img.shields.io/pypi/pyversions/upfront)](https://pypi.org/project/upfront/)
32
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/thanatchon36/upfront/blob/main/LICENSE)
33
+
34
+ See how many tokens your MCP servers, skills and instruction files cost a coding agent before
35
+ you type a word, and which tools will break in Claude Code, Codex, Gemini CLI or OpenCode.
36
+
37
+ ## The problem
38
+
39
+ > "Claude Code sends 33k tokens before reading the prompt; OpenCode sends 7k"
40
+ > — [Hacker News, 706 points](https://news.ycombinator.com/item?id=48883275); finding out took a logging proxy.
41
+
42
+ Every connected MCP server puts all of its tool schemas into the context, every skill adds its
43
+ description, and AGENTS.md / CLAUDE.md ride along on every request. Usage limits arrive early,
44
+ and Codex starts dropping skills ([codex#19679](https://github.com/openai/codex/issues/19679))
45
+ and MCP tools ([codex#44308](https://github.com/openai/codex/issues/44308)) once budgets run
46
+ out. Claude Code's `/context` shows this for Claude Code only; OpenCode closed the request as
47
+ [not planned](https://github.com/anomalyco/opencode/issues/11995).
48
+
49
+ ## Demo
50
+
51
+ ![upfront measuring a demo project with three official MCP servers](https://raw.githubusercontent.com/thanatchon36/upfront/main/docs/demo.gif)
52
+
53
+ ```console
54
+ $ uv run upfront examples/demo --yes --top 2 # in a clone of this repository
55
+ upfront 0.1.0 · examples/demo · tokens o200k_base
56
+
57
+ claude-code ≈ 6,786 before your first prompt
58
+ mcp filesystem (14 tools, project) ≈ 2,751
59
+ read_media_file ≈ 285
60
+ read_text_file ≈ 251
61
+ mcp memory (9 tools, project) ≈ 2,365
62
+ create_entities ≈ 349
63
+ search_nodes ≈ 320
64
+ mcp everything (13 tools, project) ≈ 1,602
65
+ gzip-file-as-resource ≈ 239
66
+ get-structured-content ≈ 186
67
+ skills (2, name + description) ≈ 33 bodies ≈ 48 load on demand
68
+ CLAUDE.md ≈ 35
69
+ ...
70
+ compatibility
71
+ error codex issue-scenarios.files.read: 'files.read' (10 chars) is not a valid OpenAI function name
72
+ [openai-tool-name] https://github.com/openai/openai-python/blob/main/src/openai/types/shared_params/function_definition.py
73
+ ```
74
+
75
+ The demo's servers replay `tools/list` snapshots of the official
76
+ [filesystem, memory and everything](https://github.com/modelcontextprotocol/servers) reference
77
+ servers (1.0.0), so the numbers above are what those servers really cost.
78
+
79
+ ## Install
80
+
81
+ ```bash
82
+ uvx --from git+https://github.com/thanatchon36/upfront upfront # run from your project, no install
83
+ pip install upfront # once v0.1.0 is on PyPI
84
+ ```
85
+
86
+ Python 3.11+. Then, in a project:
87
+
88
+ ```bash
89
+ upfront # skills, instruction files and the list of servers; starts nothing
90
+ upfront --yes # also start/connect to each MCP server and count its tools
91
+ ```
92
+
93
+ ## Features
94
+
95
+ - **Four harnesses, both scopes.** Reads Claude Code, Codex, Gemini CLI and OpenCode configs from the project and your home directory, including `${VAR:-default}` expansion and JSONC.
96
+ - **Real tool lists.** Talks to every stdio, Streamable HTTP and SSE server with the official MCP SDK, follows pagination, and reports failures (missing command, timeout, "auth required") per server instead of crashing.
97
+ - **Where the tokens go.** Per server and per tool, skill metadata separately from skill bodies, and every instruction file.
98
+ - **Compatibility checks with sources.** Tool names against OpenAI, Anthropic and Gemini rules, `$ref` parameters in Claude Code, non-standard formats in OpenCode, and Codex's skills budget. Every finding links the documentation or open issue it comes from.
99
+ - **CI-friendly.** `--json`, `--budget N` and `--strict` exit codes, and `--tools-file` to check a saved `tools/list` without starting anything.
100
+ - **Safe by default.** Nothing is launched without consent: it asks in a terminal and needs `--yes` elsewhere. It only ever calls `tools/list`.
101
+
102
+ ## How it compares
103
+
104
+ | | upfront | Claude Code [`/context`](https://code.claude.com/docs/en/commands) | [mcp-assert](https://github.com/blackwell-systems/mcp-assert) | [ccusage](https://github.com/ccusage/ccusage) |
105
+ |---|---|---|---|---|
106
+ | Up-front cost of MCP tools, skills, instruction files | yes, per harness | yes, Claude Code only | no | no |
107
+ | Works for Codex, Gemini CLI, OpenCode | yes | no | n/a | n/a |
108
+ | Per-client schema compatibility | yes, 6 sourced rules | no | no; 24 usability lint rules (descriptions, nesting) | no |
109
+ | Tests tool *behaviour* | no | no | yes (assertions, fuzzing) | no |
110
+ | Actual spend from past sessions | no | `/usage` | no | yes |
111
+
112
+ Use `/context` inside Claude Code, mcp-assert to test what your tools do, and
113
+ ccusage to see what you've already spent. upfront answers "what will each agent load, and what
114
+ breaks where" before you start.
115
+
116
+ ## How it works
117
+
118
+ 1. **Discover**: parse each harness's documented config files ([concepts](https://github.com/thanatchon36/upfront/blob/main/docs/concepts.md#where-upfront-looks)).
119
+ 2. **Fetch**: with consent, start each distinct server once (from the project directory, like the agent) and page through `tools/list`.
120
+ 3. **Count**: tokenize each tool's wire JSON with `o200k_base`; skill metadata and bodies separately; instruction files whole.
121
+ 4. **Check**: run the per-client rules ([table](https://github.com/thanatchon36/upfront/blob/main/docs/api.md#compatibility-rules)).
122
+
123
+ More: [quickstart](https://github.com/thanatchon36/upfront/blob/main/docs/quickstart.md) · [concepts](https://github.com/thanatchon36/upfront/blob/main/docs/concepts.md) · [FAQ](https://github.com/thanatchon36/upfront/blob/main/docs/faq.md) · [API](https://github.com/thanatchon36/upfront/blob/main/docs/api.md) · [decisions](https://github.com/thanatchon36/upfront/blob/main/docs/decisions/)
124
+
125
+ ## Limitations
126
+
127
+ - **Estimates.** One tokenizer for every model; vendors' counts differ, and clients add their own framing around tools ([ADR-0003](https://github.com/thanatchon36/upfront/blob/main/docs/decisions/ADR-0003-tokenizer.md)).
128
+ - **Not the vendor's system prompt.** Only what you add is measured.
129
+ - **Lazy loading isn't modelled.** Claude Code's tool search and OpenCode's lazy MCP loading defer some definitions; upfront reports their full cost.
130
+ - **No OAuth.** Remote servers that need a login show "auth required; not measured". Headers from your config are sent; OAuth flows are not run.
131
+ - **Root-level instruction files only**, and only the four CLI harnesses above (no Cursor or Windsurf yet).
132
+ - **Codex's 2% skills budget** depends on the model's window; upfront checks the documented 8,000-character fallback.
133
+
134
+ ## Roadmap
135
+
136
+ - **v0.2**: exact counts via vendor token-count APIs (opt-in), a `--fix` proxy that rewrites schemas per client, Cursor and Windsurf configs.
137
+ - **v0.3**: `upfront diff` between git refs for MCP server pull requests, and a GitHub Action.
138
+
139
+ ## Contributing
140
+
141
+ Bug reports with a config that reproduces the problem help most. See
142
+ [CONTRIBUTING.md](https://github.com/thanatchon36/upfront/blob/main/CONTRIBUTING.md); compatibility rules need a public source.
143
+
144
+ ## License
145
+
146
+ [MIT](https://github.com/thanatchon36/upfront/blob/main/LICENSE)