zenofmcp 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.
zenofmcp-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anuj Sadani
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,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: zenofmcp
3
+ Version: 0.1.0
4
+ Summary: The Zen of MCP: principles for designing tools that models can use well. Printed on import.
5
+ Author-email: Anuj Sadani <anuj.sadani3@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/asadani/zenofmcp
8
+ Project-URL: Issues, https://github.com/asadani/zenofmcp/issues
9
+ Project-URL: Changelog, https://github.com/asadani/zenofmcp/blob/main/CHANGELOG.md
10
+ Keywords: MCP,Model Context Protocol,AI agents,tool design,LLM,Zen
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # zenofmcp
22
+
23
+ [![CI](https://github.com/asadani/zenofmcp/actions/workflows/ci.yml/badge.svg)](https://github.com/asadani/zenofmcp/actions/workflows/ci.yml)
24
+ [![PyPI](https://img.shields.io/pypi/v/zenofmcp)](https://pypi.org/project/zenofmcp/)
25
+
26
+ ### The Zen of MCP: principles for designing tools that models can use well.
27
+
28
+ A model is only as good as the tools you hand it. These principles cover how to design, describe, protect and operate tools for models, whether you build them with the Model Context Protocol (MCP) or anything else.
29
+
30
+ `import this` gave Python a shared mindset. `import zenofmcp` does the same for this corner of AI engineering: 15 short principles you can remember, cite by number and argue about.
31
+
32
+ > Written against the MCP specification as of 2026-07-28 (stateless, no protocol sessions). The principles themselves don't depend on any spec version.
33
+
34
+ ```bash
35
+ pip install zenofmcp # or: uv pip install zenofmcp / uv add zenofmcp
36
+ uvx zenofmcp --random # run the CLI without installing (uv)
37
+ ```
38
+
39
+ ```python
40
+ >>> import zenofmcp
41
+ The Zen of MCP, by Anuj Sadani
42
+
43
+ 1. Each tool should do one thing—and its name should say which.
44
+ 2. Few sharp tools are better than many blunt ones.
45
+ ...
46
+ ```
47
+
48
+ ---
49
+
50
+ ## The principles
51
+
52
+ Numbers are stable across releases, so "see principle 3" in a review always means the same thing.
53
+
54
+ ### Design
55
+ 1. Each tool should do one thing—and its name should say which.
56
+ 2. Few sharp tools are better than many blunt ones.
57
+ 3. Design for the job, not the endpoint.
58
+
59
+ ### Describe
60
+ 4. The description is the interface.
61
+ 5. Schemas guide; validation guards.
62
+ 6. Errors should point the way forward.
63
+ 7. In the face of missing input, refuse the temptation to guess.
64
+
65
+ ### State
66
+ 8. Keep the server stateless; let handles carry the state.
67
+ 9. Long work should return a receipt, not a wait.
68
+ 10. Every call may arrive twice—make sure it only counts once.
69
+
70
+ ### Protect
71
+ 11. Borrow the caller's authority; never exceed it.
72
+ 12. The irreversible should never be implicit.
73
+ 13. Never pass outside text off as your own.
74
+
75
+ ### Operate
76
+ 14. Enough is better than everything.
77
+ 15. A published tool is a public API.
78
+
79
+ Every principle comes with an explanation and a concrete do/don't example: `zenofmcp --examples`.
80
+
81
+ ---
82
+
83
+ ## Usage
84
+
85
+ ### On import
86
+
87
+ ```python
88
+ import zenofmcp # prints the principles
89
+ from zenofmcp import verbose # prints them with explanations
90
+ ```
91
+
92
+ Set `ZENOFMCP_QUIET=1` to import without printing.
93
+
94
+ ### Command line
95
+
96
+ ```bash
97
+ zenofmcp # the principles
98
+ zenofmcp --verbose # with explanations
99
+ zenofmcp --examples # with a do/don't example for each
100
+ zenofmcp --themes # grouped by theme
101
+ zenofmcp -n 3 # one principle in full
102
+ zenofmcp --random # one at random: a daily reminder for your shell profile
103
+ zenofmcp --checklist # Markdown checklist for PRs and agent instructions
104
+ zenofmcp --json # machine-readable
105
+ ```
106
+
107
+ `python -m zenofmcp` works the same way.
108
+
109
+ ### As data
110
+
111
+ ```python
112
+ import os; os.environ["ZENOFMCP_QUIET"] = "1"
113
+ import zenofmcp
114
+
115
+ zenofmcp.get(3).text # "Design for the job, not the endpoint."
116
+ zenofmcp.by_theme("design") # list of Principle objects
117
+ [p.text for p in zenofmcp.PRINCIPLES]
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Putting it into your workflow
123
+
124
+ A slogan is not a process. The principles help most where decisions are made:
125
+
126
+ - **Pull requests.** Paste `zenofmcp --checklist` into `.github/pull_request_template.md`. Reviewers can then point to a principle by number.
127
+ - **Coding agents.** Add the checklist (or `zenofmcp --themes`) to `AGENTS.md`, `CLAUDE.md` or your editor's rules file, so your agent works by the same standard you review by.
128
+ - **Onboarding.** `zenofmcp --examples` is a short read for anyone new to the team's approach.
129
+
130
+ ---
131
+
132
+ ## What this is, and isn't
133
+
134
+ - It **is** a compact, opinionated philosophy and a shared vocabulary for teams.
135
+ - It **isn't** a linter, a framework or a replacement for engineering judgment.
136
+ - It's **vendor-neutral**: no principle depends on a particular model, framework or vendor.
137
+
138
+ ---
139
+
140
+ ## Contributing
141
+
142
+ The principles should evolve through discussion, not by decree. Propose a new principle, a rewording or a better example by opening an issue. See [CONTRIBUTING.md](CONTRIBUTING.md).
143
+
144
+ ## License
145
+
146
+ [MIT](LICENSE)
@@ -0,0 +1,126 @@
1
+ # zenofmcp
2
+
3
+ [![CI](https://github.com/asadani/zenofmcp/actions/workflows/ci.yml/badge.svg)](https://github.com/asadani/zenofmcp/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/zenofmcp)](https://pypi.org/project/zenofmcp/)
5
+
6
+ ### The Zen of MCP: principles for designing tools that models can use well.
7
+
8
+ A model is only as good as the tools you hand it. These principles cover how to design, describe, protect and operate tools for models, whether you build them with the Model Context Protocol (MCP) or anything else.
9
+
10
+ `import this` gave Python a shared mindset. `import zenofmcp` does the same for this corner of AI engineering: 15 short principles you can remember, cite by number and argue about.
11
+
12
+ > Written against the MCP specification as of 2026-07-28 (stateless, no protocol sessions). The principles themselves don't depend on any spec version.
13
+
14
+ ```bash
15
+ pip install zenofmcp # or: uv pip install zenofmcp / uv add zenofmcp
16
+ uvx zenofmcp --random # run the CLI without installing (uv)
17
+ ```
18
+
19
+ ```python
20
+ >>> import zenofmcp
21
+ The Zen of MCP, by Anuj Sadani
22
+
23
+ 1. Each tool should do one thing—and its name should say which.
24
+ 2. Few sharp tools are better than many blunt ones.
25
+ ...
26
+ ```
27
+
28
+ ---
29
+
30
+ ## The principles
31
+
32
+ Numbers are stable across releases, so "see principle 3" in a review always means the same thing.
33
+
34
+ ### Design
35
+ 1. Each tool should do one thing—and its name should say which.
36
+ 2. Few sharp tools are better than many blunt ones.
37
+ 3. Design for the job, not the endpoint.
38
+
39
+ ### Describe
40
+ 4. The description is the interface.
41
+ 5. Schemas guide; validation guards.
42
+ 6. Errors should point the way forward.
43
+ 7. In the face of missing input, refuse the temptation to guess.
44
+
45
+ ### State
46
+ 8. Keep the server stateless; let handles carry the state.
47
+ 9. Long work should return a receipt, not a wait.
48
+ 10. Every call may arrive twice—make sure it only counts once.
49
+
50
+ ### Protect
51
+ 11. Borrow the caller's authority; never exceed it.
52
+ 12. The irreversible should never be implicit.
53
+ 13. Never pass outside text off as your own.
54
+
55
+ ### Operate
56
+ 14. Enough is better than everything.
57
+ 15. A published tool is a public API.
58
+
59
+ Every principle comes with an explanation and a concrete do/don't example: `zenofmcp --examples`.
60
+
61
+ ---
62
+
63
+ ## Usage
64
+
65
+ ### On import
66
+
67
+ ```python
68
+ import zenofmcp # prints the principles
69
+ from zenofmcp import verbose # prints them with explanations
70
+ ```
71
+
72
+ Set `ZENOFMCP_QUIET=1` to import without printing.
73
+
74
+ ### Command line
75
+
76
+ ```bash
77
+ zenofmcp # the principles
78
+ zenofmcp --verbose # with explanations
79
+ zenofmcp --examples # with a do/don't example for each
80
+ zenofmcp --themes # grouped by theme
81
+ zenofmcp -n 3 # one principle in full
82
+ zenofmcp --random # one at random: a daily reminder for your shell profile
83
+ zenofmcp --checklist # Markdown checklist for PRs and agent instructions
84
+ zenofmcp --json # machine-readable
85
+ ```
86
+
87
+ `python -m zenofmcp` works the same way.
88
+
89
+ ### As data
90
+
91
+ ```python
92
+ import os; os.environ["ZENOFMCP_QUIET"] = "1"
93
+ import zenofmcp
94
+
95
+ zenofmcp.get(3).text # "Design for the job, not the endpoint."
96
+ zenofmcp.by_theme("design") # list of Principle objects
97
+ [p.text for p in zenofmcp.PRINCIPLES]
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Putting it into your workflow
103
+
104
+ A slogan is not a process. The principles help most where decisions are made:
105
+
106
+ - **Pull requests.** Paste `zenofmcp --checklist` into `.github/pull_request_template.md`. Reviewers can then point to a principle by number.
107
+ - **Coding agents.** Add the checklist (or `zenofmcp --themes`) to `AGENTS.md`, `CLAUDE.md` or your editor's rules file, so your agent works by the same standard you review by.
108
+ - **Onboarding.** `zenofmcp --examples` is a short read for anyone new to the team's approach.
109
+
110
+ ---
111
+
112
+ ## What this is, and isn't
113
+
114
+ - It **is** a compact, opinionated philosophy and a shared vocabulary for teams.
115
+ - It **isn't** a linter, a framework or a replacement for engineering judgment.
116
+ - It's **vendor-neutral**: no principle depends on a particular model, framework or vendor.
117
+
118
+ ---
119
+
120
+ ## Contributing
121
+
122
+ The principles should evolve through discussion, not by decree. Propose a new principle, a rewording or a better example by opening an issue. See [CONTRIBUTING.md](CONTRIBUTING.md).
123
+
124
+ ## License
125
+
126
+ [MIT](LICENSE)
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "zenofmcp"
7
+ version = "0.1.0"
8
+ authors = [
9
+ {name = "Anuj Sadani", email = "anuj.sadani3@gmail.com"}
10
+ ]
11
+ description = "The Zen of MCP: principles for designing tools that models can use well. Printed on import."
12
+ readme = "README.md"
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
15
+ requires-python = ">=3.10"
16
+ keywords = ["MCP", "Model Context Protocol", "AI agents", "tool design", "LLM", "Zen"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Operating System :: OS Independent",
22
+ "Topic :: Software Development",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/asadani/zenofmcp"
27
+ Issues = "https://github.com/asadani/zenofmcp/issues"
28
+ Changelog = "https://github.com/asadani/zenofmcp/blob/main/CHANGELOG.md"
29
+
30
+ [project.scripts]
31
+ zenofmcp = "zenofmcp.__main__:main"
32
+
33
+ [tool.setuptools]
34
+ packages = ["zenofmcp"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,109 @@
1
+ import contextlib
2
+ import importlib
3
+ import io
4
+ import json
5
+ import os
6
+ import subprocess
7
+ import sys
8
+ import unittest
9
+
10
+ os.environ["ZENOFMCP_QUIET"] = "1"
11
+
12
+ import zenofmcp # noqa: E402
13
+ from zenofmcp import render # noqa: E402
14
+ from zenofmcp.__main__ import main # noqa: E402
15
+
16
+ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
+ N = len(zenofmcp.PRINCIPLES)
18
+
19
+
20
+ def run_cli(*args):
21
+ buf = io.StringIO()
22
+ with contextlib.redirect_stdout(buf):
23
+ main(list(args))
24
+ return buf.getvalue()
25
+
26
+
27
+ def run_py(args, quiet):
28
+ env = dict(os.environ)
29
+ env.pop("ZENOFMCP_QUIET", None)
30
+ if quiet:
31
+ env["ZENOFMCP_QUIET"] = "1"
32
+ return subprocess.run(
33
+ [sys.executable] + args, cwd=ROOT, env=env,
34
+ capture_output=True, text=True, encoding="utf-8", check=True,
35
+ ).stdout
36
+
37
+
38
+ class TestData(unittest.TestCase):
39
+ def test_stable_numbers(self):
40
+ self.assertEqual([p.number for p in zenofmcp.PRINCIPLES], list(range(1, N + 1)))
41
+
42
+ def test_every_principle_complete_and_themed(self):
43
+ for p in zenofmcp.PRINCIPLES:
44
+ self.assertIn(p.theme, zenofmcp.THEMES)
45
+ for field in (p.text, p.explanation, p.do, p.dont):
46
+ self.assertTrue(field.strip(), p.number)
47
+
48
+ def test_every_theme_used(self):
49
+ for theme in zenofmcp.THEMES:
50
+ self.assertTrue(zenofmcp.by_theme(theme))
51
+
52
+ def test_texts_are_unique(self):
53
+ texts = [p.text for p in zenofmcp.PRINCIPLES]
54
+ self.assertEqual(len(texts), len(set(texts)))
55
+
56
+ def test_lookup(self):
57
+ self.assertEqual(zenofmcp.get(1).number, 1)
58
+ with self.assertRaises(KeyError):
59
+ zenofmcp.get(N + 1)
60
+ with self.assertRaises(ValueError):
61
+ zenofmcp.by_theme("vibes")
62
+
63
+ def test_version_matches_pyproject(self):
64
+ with open(os.path.join(ROOT, "pyproject.toml"), encoding="utf-8") as f:
65
+ self.assertIn('version = "%s"' % zenofmcp.__version__, f.read())
66
+
67
+
68
+ class TestImportSideEffect(unittest.TestCase):
69
+ def test_import_prints_like_import_this(self):
70
+ self.assertIn("1. " + zenofmcp.PRINCIPLES[0].text, run_py(["-c", "import zenofmcp"], quiet=False))
71
+
72
+ def test_quiet_env_silences_import(self):
73
+ self.assertEqual(run_py(["-c", "import zenofmcp"], quiet=True), "")
74
+
75
+ def test_python_dash_m_prints_once(self):
76
+ out = run_py(["-m", "zenofmcp", "--themes"], quiet=False)
77
+ self.assertIn("by theme", out)
78
+ self.assertNotIn("\n1. " + zenofmcp.PRINCIPLES[0].text, out)
79
+
80
+ def test_verbose_module(self):
81
+ mod = importlib.import_module("zenofmcp.verbose")
82
+ self.assertIn("Verbose Edition", mod.VERBOSE_ZEN)
83
+
84
+
85
+ class TestCLI(unittest.TestCase):
86
+ def test_default_is_concise(self):
87
+ self.assertEqual(run_cli().rstrip("\n"), render.concise().rstrip("\n"))
88
+
89
+ def test_examples_include_do_and_dont(self):
90
+ out = run_cli("--examples")
91
+ self.assertEqual(out.count("Do:"), N)
92
+ self.assertEqual(out.count("Don't:"), N)
93
+
94
+ def test_checklist_is_markdown(self):
95
+ self.assertEqual(run_cli("--checklist").count("- [ ]"), N)
96
+
97
+ def test_json_round_trips(self):
98
+ self.assertEqual(len(json.loads(run_cli("--json"))["principles"]), N)
99
+
100
+ def test_single_principle(self):
101
+ self.assertTrue(run_cli("-n", "1").startswith("1. "))
102
+
103
+ def test_bad_number_exits(self):
104
+ with self.assertRaises(SystemExit), contextlib.redirect_stderr(io.StringIO()):
105
+ run_cli("-n", str(N + 50))
106
+
107
+
108
+ if __name__ == "__main__":
109
+ unittest.main()
@@ -0,0 +1,32 @@
1
+ """The Zen of MCP. Like ``import this``, importing prints the principles.
2
+
3
+ Set the environment variable ZENOFMCP_QUIET=1 to import without printing,
4
+ e.g. when using ``zenofmcp.PRINCIPLES`` as data.
5
+ """
6
+
7
+ import os
8
+ import sys
9
+
10
+ from .principles import PRINCIPLES, THEMES, Principle, by_theme, get
11
+ from .render import concise as _concise
12
+
13
+ __version__ = "0.1.0"
14
+ __author__ = "Anuj Sadani"
15
+ __all__ = ["PRINCIPLES", "THEMES", "Principle", "by_theme", "get", "ZEN_CONCISE"]
16
+
17
+ ZEN_CONCISE = _concise()
18
+
19
+
20
+ def _running_cli() -> bool:
21
+ # `zenofmcp ...` console script, or `python -m zenofmcp ...`: the CLI prints instead.
22
+ if os.path.basename(sys.argv[0] or "").split(".")[0] == "zenofmcp":
23
+ return True
24
+ orig = sys.orig_argv
25
+ if "-m" in orig:
26
+ i = orig.index("-m")
27
+ return i + 1 < len(orig) and orig[i + 1] == "zenofmcp"
28
+ return False
29
+
30
+
31
+ if not os.environ.get("ZENOFMCP_QUIET") and not _running_cli():
32
+ print(ZEN_CONCISE)
@@ -0,0 +1,48 @@
1
+ """Command line: ``zenofmcp`` or ``python -m zenofmcp``."""
2
+
3
+ import argparse
4
+ import random
5
+ import sys
6
+
7
+ from . import __version__
8
+ from . import render
9
+ from .principles import PRINCIPLES, get
10
+
11
+
12
+ def main(argv=None) -> int:
13
+ parser = argparse.ArgumentParser(prog="zenofmcp", description="The Zen of MCP.")
14
+ mode = parser.add_mutually_exclusive_group()
15
+ mode.add_argument("-v", "--verbose", action="store_true", help="principles with explanations")
16
+ mode.add_argument("-e", "--examples", action="store_true", help="verbose, plus a do/don't example for each")
17
+ mode.add_argument("-t", "--themes", action="store_true", help="grouped by theme: design, describe, state, protect, operate")
18
+ mode.add_argument("-n", "--number", type=int, metavar="N", help="show one principle in full (1-%d)" % len(PRINCIPLES))
19
+ mode.add_argument("-r", "--random", action="store_true", help="one random principle, e.g. for a daily reminder")
20
+ mode.add_argument("--checklist", action="store_true", help="Markdown checklist for PR templates or AGENTS.md")
21
+ mode.add_argument("--json", action="store_true", help="machine-readable output")
22
+ parser.add_argument("--version", action="version", version="zenofmcp " + __version__)
23
+ args = parser.parse_args(argv)
24
+
25
+ if args.verbose:
26
+ out = render.verbose()
27
+ elif args.examples:
28
+ out = render.verbose(examples=True)
29
+ elif args.themes:
30
+ out = render.themed()
31
+ elif args.checklist:
32
+ out = render.checklist()
33
+ elif args.json:
34
+ out = render.as_json()
35
+ elif args.number is not None or args.random:
36
+ try:
37
+ p = random.choice(PRINCIPLES) if args.random else get(args.number)
38
+ except KeyError:
39
+ parser.error("principle number must be 1-%d" % len(PRINCIPLES))
40
+ out = "%d. %s\n %s\n Do: %s\n Don't: %s" % (p.number, p.text, p.explanation, p.do, p.dont)
41
+ else:
42
+ out = render.concise()
43
+ print(out)
44
+ return 0
45
+
46
+
47
+ if __name__ == "__main__":
48
+ sys.exit(main())
@@ -0,0 +1,146 @@
1
+ """The principles as structured data."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Dict, List, Tuple
5
+
6
+ THEMES: Dict[str, str] = {
7
+ 'design': 'Design',
8
+ 'describe': 'Describe',
9
+ 'state': 'State',
10
+ 'protect': 'Protect',
11
+ 'operate': 'Operate',
12
+ }
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class Principle:
17
+ number: int
18
+ text: str
19
+ explanation: str
20
+ theme: str
21
+ do: str
22
+ dont: str
23
+
24
+
25
+ PRINCIPLES: Tuple[Principle, ...] = (
26
+ Principle(
27
+ 1, 'Each tool should do one thing—and its name should say which.',
28
+ 'Models pick tools by name and description. A tool that does one clearly named thing gets chosen correctly; a multi-purpose tool with a mode flag gets misused.',
29
+ 'design',
30
+ do='`create_invoice` and `void_invoice` as two tools.',
31
+ dont='One `invoice` tool with an `action` parameter that switches between create, void and refund.',
32
+ ),
33
+ Principle(
34
+ 2, 'Few sharp tools are better than many blunt ones.',
35
+ "Every tool in the list competes for the model's attention and context. A small set of well-scoped tools beats a large catalog of near-duplicates.",
36
+ 'design',
37
+ do='Expose the eight operations your users actually need.',
38
+ dont="Auto-generate a tool for each of your API's 140 endpoints.",
39
+ ),
40
+ Principle(
41
+ 3, 'Design for the job, not the endpoint.',
42
+ 'A tool should match a task the model is trying to complete, even if that takes several API calls behind it. Mirroring your REST API pushes orchestration onto the model, where it is slower and less reliable.',
43
+ 'design',
44
+ do='A `schedule_meeting` tool that checks availability and books in one call.',
45
+ dont='Make the model chain `list_calendars`, `get_free_busy` and `create_event` itself.',
46
+ ),
47
+ Principle(
48
+ 4, 'The description is the interface.',
49
+ "The model never reads your code; it reads the tool's description and schema. Say when to use the tool, what it changes and what it returns—and when not to use it.",
50
+ 'describe',
51
+ do='"Search open support tickets by keyword. Read-only. Returns at most 20 results, newest first."',
52
+ dont='"Ticket search tool."',
53
+ ),
54
+ Principle(
55
+ 5, 'Schemas guide; validation guards.',
56
+ "A precise schema (types, enums, required fields) steers the model toward valid calls, but it can't express every rule. Validate on the server anyway, including rules that span fields.",
57
+ 'describe',
58
+ do='Use an enum for `status`, and still reject an end date before the start date.',
59
+ dont='Assume a schema-valid call is a correct call.',
60
+ ),
61
+ Principle(
62
+ 6, 'Errors should point the way forward.',
63
+ 'The model reads your error and decides what to do next. An error that says what went wrong and how to fix it lets the model recover; a bare code makes it guess or give up.',
64
+ 'describe',
65
+ do='"No customer with ID 4821. Use search_customers to look up an ID by name."',
66
+ dont='"Error 404."',
67
+ ),
68
+ Principle(
69
+ 7, 'In the face of missing input, refuse the temptation to guess.',
70
+ 'When a required detail is missing or ambiguous, ask for it instead of inventing a default. The protocol lets a server ask the user mid-call, so guessing is a design choice, not a necessity.',
71
+ 'describe',
72
+ do='Ask which of the three "Acme" accounts the user means.',
73
+ dont='Silently pick the first match and transfer money to it.',
74
+ ),
75
+ Principle(
76
+ 8, 'Keep the server stateless; let handles carry the state.',
77
+ 'A server that keeps nothing in connection memory can answer any request on any instance. What must persist lives in shared storage or in an explicit handle (a cart ID, a draft ID) that the caller passes back. This is the direction of the MCP specification since 2026-07-28, which removed protocol sessions.',
78
+ 'state',
79
+ do='Return `draft_id` from `create_draft` and require it in `send_draft`.',
80
+ dont='Remember "the current draft" in server memory tied to a connection.',
81
+ ),
82
+ Principle(
83
+ 9, 'Long work should return a receipt, not a wait.',
84
+ 'Work that takes minutes should start, return an identifier at once, and let the caller check on progress. Holding a request open ties up connections and fails badly when anything in between times out.',
85
+ 'state',
86
+ do='Return a job ID from `start_export` and offer `get_export_status`.',
87
+ dont='Keep a request open for ten minutes while the export runs.',
88
+ ),
89
+ Principle(
90
+ 10, 'Every call may arrive twice—make sure it only counts once.',
91
+ "Networks fail and clients retry, sometimes against a different server instance. Design writes so a repeated call is recognized and doesn't double-charge, double-send or double-book.",
92
+ 'state',
93
+ do='Accept an idempotency key and return the original result for a repeat.',
94
+ dont='Create a second payment because the first response was lost.',
95
+ ),
96
+ Principle(
97
+ 11, "Borrow the caller's authority; never exceed it.",
98
+ "A tool should act with the permissions of the user it serves, not a shared all-powerful account. The model should never be able to do through your tool what the user couldn't do directly.",
99
+ 'protect',
100
+ do="Call downstream APIs with the user's scoped token.",
101
+ dont="Use one admin key for every user's requests.",
102
+ ),
103
+ Principle(
104
+ 12, 'The irreversible should never be implicit.',
105
+ 'Keep reading and writing in separate tools, and make destructive actions explicit and confirmable. Nothing should be deleted or sent as a side effect of a call that looked harmless.',
106
+ 'protect',
107
+ do='Separate `preview_bulk_delete` from `confirm_bulk_delete`.',
108
+ dont='Have `cleanup_inbox` quietly delete messages older than 30 days.',
109
+ ),
110
+ Principle(
111
+ 13, 'Never pass outside text off as your own.',
112
+ "Web pages, emails and documents can contain text written to manipulate a model. Keep outside content separate from your tool's own messages and keep its source, so the client and the model can treat it as untrusted. Labeling doesn't stop prompt injection, but blending makes it easier.",
113
+ 'protect',
114
+ do='Return fetched text in an `external_content` field with its URL, apart from your own status fields.',
115
+ dont="Merge an email's body into your tool's own status message.",
116
+ ),
117
+ Principle(
118
+ 14, 'Enough is better than everything.',
119
+ 'Large results waste context and bury the useful part. Return what the model needs to act, offer pagination or filters for the rest, and say when results were truncated.',
120
+ 'operate',
121
+ do='Return the top 20 matches with a `next_cursor` and a total count.',
122
+ dont='Return 5,000 log lines in one response.',
123
+ ),
124
+ Principle(
125
+ 15, 'A published tool is a public API.',
126
+ "Once clients and prompts depend on a tool's name, parameters and behavior, changing them breaks things you can't see. Version changes, deprecate before removing, and give people time to move.",
127
+ 'operate',
128
+ do='Add new parameters as optional, and announce removals well ahead.',
129
+ dont='Rename `get_user` to `fetch_user` in a patch release.',
130
+ ),
131
+ )
132
+
133
+
134
+ def by_theme(theme: str) -> List[Principle]:
135
+ """Return the principles in one theme (design, describe, state, protect, operate)."""
136
+ if theme not in THEMES:
137
+ raise ValueError("unknown theme %r; choose from %s" % (theme, ", ".join(THEMES)))
138
+ return [p for p in PRINCIPLES if p.theme == theme]
139
+
140
+
141
+ def get(number: int) -> Principle:
142
+ """Return a principle by its stable number."""
143
+ for p in PRINCIPLES:
144
+ if p.number == number:
145
+ return p
146
+ raise KeyError(number)
@@ -0,0 +1,53 @@
1
+ """Turn the principles into text: concise, verbose, by theme, checklist, JSON."""
2
+
3
+ import json
4
+ from dataclasses import asdict
5
+
6
+ from .principles import PRINCIPLES, THEMES, by_theme
7
+
8
+ TITLE = "The Zen of MCP, by Anuj Sadani"
9
+
10
+
11
+ def concise() -> str:
12
+ lines = [TITLE, ""]
13
+ lines += ["%d. %s" % (p.number, p.text) for p in PRINCIPLES]
14
+ return "\n".join(lines) + "\n"
15
+
16
+
17
+ def verbose(examples: bool = False) -> str:
18
+ lines = ["The Zen of MCP (Verbose Edition)", "by Anuj Sadani", ""]
19
+ for p in PRINCIPLES:
20
+ pad = " " * (len(str(p.number)) + 2)
21
+ lines.append("%d. %s" % (p.number, p.text))
22
+ lines.append("%s— %s" % (pad, p.explanation))
23
+ if examples:
24
+ lines.append("%sDo: %s" % (pad, p.do))
25
+ lines.append("%sDon't: %s" % (pad, p.dont))
26
+ lines.append("")
27
+ return "\n".join(lines)
28
+
29
+
30
+ def themed() -> str:
31
+ lines = [TITLE + " — by theme", ""]
32
+ for key, name in THEMES.items():
33
+ lines.append(name)
34
+ lines += [" %d. %s" % (p.number, p.text) for p in by_theme(key)]
35
+ lines.append("")
36
+ return "\n".join(lines)
37
+
38
+
39
+ def checklist() -> str:
40
+ """Markdown checklist for PR templates, AGENTS.md or CLAUDE.md."""
41
+ lines = ["## MCP tool review checklist (Zen of MCP)", ""]
42
+ for key, name in THEMES.items():
43
+ lines.append("### " + name)
44
+ lines += ["- [ ] %s _(#%d)_" % (p.do, p.number) for p in by_theme(key)]
45
+ lines.append("")
46
+ return "\n".join(lines)
47
+
48
+
49
+ def as_json() -> str:
50
+ return json.dumps(
51
+ {"themes": THEMES, "principles": [asdict(p) for p in PRINCIPLES]},
52
+ ensure_ascii=False, indent=2,
53
+ )
@@ -0,0 +1,10 @@
1
+ """``from zenofmcp import verbose`` prints the verbose edition."""
2
+
3
+ import os
4
+
5
+ from .render import verbose as _verbose
6
+
7
+ VERBOSE_ZEN = _verbose()
8
+
9
+ if not os.environ.get("ZENOFMCP_QUIET"):
10
+ print(VERBOSE_ZEN)
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: zenofmcp
3
+ Version: 0.1.0
4
+ Summary: The Zen of MCP: principles for designing tools that models can use well. Printed on import.
5
+ Author-email: Anuj Sadani <anuj.sadani3@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/asadani/zenofmcp
8
+ Project-URL: Issues, https://github.com/asadani/zenofmcp/issues
9
+ Project-URL: Changelog, https://github.com/asadani/zenofmcp/blob/main/CHANGELOG.md
10
+ Keywords: MCP,Model Context Protocol,AI agents,tool design,LLM,Zen
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # zenofmcp
22
+
23
+ [![CI](https://github.com/asadani/zenofmcp/actions/workflows/ci.yml/badge.svg)](https://github.com/asadani/zenofmcp/actions/workflows/ci.yml)
24
+ [![PyPI](https://img.shields.io/pypi/v/zenofmcp)](https://pypi.org/project/zenofmcp/)
25
+
26
+ ### The Zen of MCP: principles for designing tools that models can use well.
27
+
28
+ A model is only as good as the tools you hand it. These principles cover how to design, describe, protect and operate tools for models, whether you build them with the Model Context Protocol (MCP) or anything else.
29
+
30
+ `import this` gave Python a shared mindset. `import zenofmcp` does the same for this corner of AI engineering: 15 short principles you can remember, cite by number and argue about.
31
+
32
+ > Written against the MCP specification as of 2026-07-28 (stateless, no protocol sessions). The principles themselves don't depend on any spec version.
33
+
34
+ ```bash
35
+ pip install zenofmcp # or: uv pip install zenofmcp / uv add zenofmcp
36
+ uvx zenofmcp --random # run the CLI without installing (uv)
37
+ ```
38
+
39
+ ```python
40
+ >>> import zenofmcp
41
+ The Zen of MCP, by Anuj Sadani
42
+
43
+ 1. Each tool should do one thing—and its name should say which.
44
+ 2. Few sharp tools are better than many blunt ones.
45
+ ...
46
+ ```
47
+
48
+ ---
49
+
50
+ ## The principles
51
+
52
+ Numbers are stable across releases, so "see principle 3" in a review always means the same thing.
53
+
54
+ ### Design
55
+ 1. Each tool should do one thing—and its name should say which.
56
+ 2. Few sharp tools are better than many blunt ones.
57
+ 3. Design for the job, not the endpoint.
58
+
59
+ ### Describe
60
+ 4. The description is the interface.
61
+ 5. Schemas guide; validation guards.
62
+ 6. Errors should point the way forward.
63
+ 7. In the face of missing input, refuse the temptation to guess.
64
+
65
+ ### State
66
+ 8. Keep the server stateless; let handles carry the state.
67
+ 9. Long work should return a receipt, not a wait.
68
+ 10. Every call may arrive twice—make sure it only counts once.
69
+
70
+ ### Protect
71
+ 11. Borrow the caller's authority; never exceed it.
72
+ 12. The irreversible should never be implicit.
73
+ 13. Never pass outside text off as your own.
74
+
75
+ ### Operate
76
+ 14. Enough is better than everything.
77
+ 15. A published tool is a public API.
78
+
79
+ Every principle comes with an explanation and a concrete do/don't example: `zenofmcp --examples`.
80
+
81
+ ---
82
+
83
+ ## Usage
84
+
85
+ ### On import
86
+
87
+ ```python
88
+ import zenofmcp # prints the principles
89
+ from zenofmcp import verbose # prints them with explanations
90
+ ```
91
+
92
+ Set `ZENOFMCP_QUIET=1` to import without printing.
93
+
94
+ ### Command line
95
+
96
+ ```bash
97
+ zenofmcp # the principles
98
+ zenofmcp --verbose # with explanations
99
+ zenofmcp --examples # with a do/don't example for each
100
+ zenofmcp --themes # grouped by theme
101
+ zenofmcp -n 3 # one principle in full
102
+ zenofmcp --random # one at random: a daily reminder for your shell profile
103
+ zenofmcp --checklist # Markdown checklist for PRs and agent instructions
104
+ zenofmcp --json # machine-readable
105
+ ```
106
+
107
+ `python -m zenofmcp` works the same way.
108
+
109
+ ### As data
110
+
111
+ ```python
112
+ import os; os.environ["ZENOFMCP_QUIET"] = "1"
113
+ import zenofmcp
114
+
115
+ zenofmcp.get(3).text # "Design for the job, not the endpoint."
116
+ zenofmcp.by_theme("design") # list of Principle objects
117
+ [p.text for p in zenofmcp.PRINCIPLES]
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Putting it into your workflow
123
+
124
+ A slogan is not a process. The principles help most where decisions are made:
125
+
126
+ - **Pull requests.** Paste `zenofmcp --checklist` into `.github/pull_request_template.md`. Reviewers can then point to a principle by number.
127
+ - **Coding agents.** Add the checklist (or `zenofmcp --themes`) to `AGENTS.md`, `CLAUDE.md` or your editor's rules file, so your agent works by the same standard you review by.
128
+ - **Onboarding.** `zenofmcp --examples` is a short read for anyone new to the team's approach.
129
+
130
+ ---
131
+
132
+ ## What this is, and isn't
133
+
134
+ - It **is** a compact, opinionated philosophy and a shared vocabulary for teams.
135
+ - It **isn't** a linter, a framework or a replacement for engineering judgment.
136
+ - It's **vendor-neutral**: no principle depends on a particular model, framework or vendor.
137
+
138
+ ---
139
+
140
+ ## Contributing
141
+
142
+ The principles should evolve through discussion, not by decree. Propose a new principle, a rewording or a better example by opening an issue. See [CONTRIBUTING.md](CONTRIBUTING.md).
143
+
144
+ ## License
145
+
146
+ [MIT](LICENSE)
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ tests/test_zenofmcp.py
5
+ zenofmcp/__init__.py
6
+ zenofmcp/__main__.py
7
+ zenofmcp/principles.py
8
+ zenofmcp/render.py
9
+ zenofmcp/verbose.py
10
+ zenofmcp.egg-info/PKG-INFO
11
+ zenofmcp.egg-info/SOURCES.txt
12
+ zenofmcp.egg-info/dependency_links.txt
13
+ zenofmcp.egg-info/entry_points.txt
14
+ zenofmcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ zenofmcp = zenofmcp.__main__:main
@@ -0,0 +1 @@
1
+ zenofmcp