Skip to content

Commit a7307d7

Browse files
committed
Initial commit
0 parents  commit a7307d7

64 files changed

Lines changed: 10008 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.cjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
parser: "@typescript-eslint/parser",
5+
parserOptions: {
6+
ecmaVersion: 2022,
7+
sourceType: "module",
8+
},
9+
plugins: ["@typescript-eslint"],
10+
extends: [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
13+
],
14+
ignorePatterns: ["dist", "node_modules", "coverage", "tests/fixtures/echo-mcp-server/dist"],
15+
rules: {
16+
"@typescript-eslint/no-explicit-any": "off",
17+
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
18+
"no-console": ["warn", { allow: ["warn", "error"] }],
19+
},
20+
};

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: test (node ${{ matrix.node }} on ${{ matrix.os }})
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, windows-latest, macos-latest]
20+
node: ["20", "22"]
21+
runs-on: ${{ matrix.os }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: pnpm/action-setup@v4
25+
with:
26+
version: 10
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node }}
30+
cache: pnpm
31+
32+
- name: Install
33+
run: pnpm install --frozen-lockfile=false
34+
35+
- name: Typecheck
36+
run: pnpm typecheck
37+
38+
- name: Test
39+
run: pnpm test
40+
41+
- name: Build
42+
run: pnpm build
43+
44+
- name: Smoke-test the CLI
45+
shell: bash
46+
run: |
47+
node bin/mcp-diet --version
48+
node bin/mcp-diet measure --config examples/demo.config.json

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
publish:
10+
name: publish to npm
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: pnpm/action-setup@v4
18+
with:
19+
version: 10
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
registry-url: "https://registry.npmjs.org"
24+
cache: pnpm
25+
26+
- name: Install
27+
run: pnpm install --frozen-lockfile=false
28+
29+
- name: Test
30+
run: pnpm test
31+
32+
- name: Build
33+
run: pnpm build
34+
35+
- name: Verify package matches tag
36+
run: |
37+
PKG_VERSION=$(node -p "require('./package.json').version")
38+
TAG_VERSION="${GITHUB_REF_NAME#v}"
39+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
40+
echo "package.json version ($PKG_VERSION) does not match tag ($TAG_VERSION)"
41+
exit 1
42+
fi
43+
44+
- name: Publish to npm
45+
run: pnpm publish --access public --no-git-checks --provenance
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.mcp-diet/
5+
*.log
6+
.DS_Store
7+
.env
8+
.env.local
9+
.idea/
10+
.vscode/
11+
*.tsbuildinfo
12+
bench/sandbox/
13+
bench/results/*.json
14+
!bench/results/.gitkeep

.npmignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
src/
2+
tests/
3+
.github/
4+
.cursor/
5+
*.tsbuildinfo
6+
tsconfig.json
7+
tsup.config.ts
8+
vitest.config.ts
9+
.eslintrc*
10+
.prettierrc*
11+
coverage/
12+
.mcp-diet/

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"arrowParens": "always"
8+
}

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Contributing to mcp-diet
2+
3+
Thanks for your interest! `mcp-diet` is a small project; a quick PR is usually faster than a long discussion.
4+
5+
## Local setup
6+
7+
```bash
8+
pnpm install
9+
pnpm typecheck
10+
pnpm test
11+
pnpm build
12+
```
13+
14+
`pnpm test` runs unit + integration suites. The integration tests spawn a local fixture MCP server over stdio, so they need Node 20+ but no network.
15+
16+
## Running the CLI in dev
17+
18+
```bash
19+
pnpm dlx tsx src/cli.ts measure --config examples/demo.config.json
20+
```
21+
22+
## Style
23+
24+
- TypeScript strict mode is on. Don't disable it.
25+
- Prefer the lowest-level MCP SDK primitives (`Server`, `setRequestHandler`) for proxy code — `McpServer.registerTool` is for static tool authors.
26+
- Keep the shrinker deterministic: same input → same output bytes. If you need an LLM, do it offline and cache the result.
27+
- Logs go through `pino`. When stdio is the inbound transport, **everything** goes to stderr — never `console.log`.
28+
29+
## Commit messages
30+
31+
Conventional commits are nice but not enforced. A short imperative summary is fine.
32+
33+
## Releasing (maintainers)
34+
35+
1. Bump `version` in `package.json`.
36+
2. Push a `vX.Y.Z` tag.
37+
3. The `release.yml` workflow runs the tests and publishes to npm.
38+
39+
## Reporting issues
40+
41+
Please include:
42+
43+
- the version of `mcp-diet` (`mcp-diet --version`),
44+
- the **redacted** config (use `mcp-diet validate-config` — it strips token-like fields),
45+
- a few lines of `.mcp-diet/trace.ndjson` if relevant.
46+
47+
By contributing, you agree your work is licensed under the same [MIT license](LICENSE) as the project.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 mcp-diet contributors
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 commit comments

Comments
 (0)