math-logic-mcp 0.2.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.
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined in Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or Object
36
+ form, made available under the License, as indicated by a copyright
37
+ notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in modifications or
40
+ additions to the Work or Derivative Works thereof, that, as a whole,
41
+ an original work of authorship, would be included, in the absence of
42
+ a waiver, in the "Derivative Works" of the Work.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original Work and any Derivative Works thereof, that is intentionally
46
+ submitted to, or received by, Licensor for inclusion in the Work by
47
+ the copyright owner or by an individual or Legal Entity authorized to
48
+ submit on behalf of the copyright owner. For the purposes of this
49
+ definition, "submitted" means any form of electronic, verbal, or
50
+ written communication sent to the Licensor or its representatives.
51
+
52
+ "Contributor" shall mean Licensor and any individual or Legal Entity
53
+ on behalf of whom a Contribution has been received by Licensor and
54
+ subsequently incorporated within the Work.
55
+
56
+ 2. Grant of Copyright License. Subject to the terms and conditions of
57
+ this License, each Contributor hereby grants to You a perpetual,
58
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
59
+ copyright license to reproduce, prepare Derivative Works of,
60
+ publicly display, publicly perform, distribute, and sublicense copies
61
+ of the Work and such Derivative Works in Source or Object form.
62
+
63
+ 3. Grant of Patent License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ (except as stated in this section) patent license to make, have made,
67
+ use, offer to sell, sell, import, and otherwise transfer the Work.
68
+
69
+ 4. Redistribution. You may reproduce and distribute copies of the Work
70
+ or Derivative Works thereof in any medium, with or without
71
+ modifications, and in Source or Object form, provided that You meet
72
+ the following conditions:
73
+
74
+ (a) You must give any other recipients of the Work or Derivative Works
75
+ a copy of this License; and
76
+
77
+ (b) You must cause any modified files to carry prominent notices
78
+ stating that You changed the files; and
79
+
80
+ (c) You must retain, in the Source form of any Derivative Works
81
+ that You distribute, all copyright, patent, license, and
82
+ attribution notices from the Source form of the Work; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file, then any Derivative
85
+ Works that You distribute must include a readable copy of the
86
+ attribution notices.
87
+
88
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
89
+ any Contribution intentionally submitted for inclusion in the Work
90
+ by You to the Licensor shall be under the terms and conditions of
91
+ this License, without limitation of any additional terms or conditions.
92
+
93
+ 6. Trademarks. This License does not grant permission to use the trade
94
+ names, trademarks, service marks, or product names of the Licensor.
95
+
96
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed
97
+ to in writing, Licensor provides the Work (and each Contributor
98
+ provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
99
+ OR CONDITIONS OF ANY KIND, either express or implied, including,
100
+ without limitation, any warranties or title, non-infringement,
101
+ merchantability, or fitness for a particular purpose.
102
+
103
+ 8. Limitation of Liability. In no event and under no legal theory,
104
+ whether in tort (including negligence), contract, or otherwise,
105
+ unless required by applicable law (such as cases of deliberate and
106
+ gross negligence) or agreed to in writing, shall any Contributor be
107
+ liable to You for damages.
108
+
109
+ 9. Accepting Warranty or Additional Liability. While redistributing
110
+ the Work or Derivative Works thereof, You may choose to offer, and
111
+ charge a fee for, acceptance of support, warranty, indemnity, or
112
+ other liability obligations and/or rights consistent with this
113
+ License.
114
+
115
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: math-logic-mcp
3
+ Version: 0.2.0
4
+ Summary: MCP server providing verified math & logic tools for small LLMs (Mistral, Llama, DeepSeek)
5
+ Author: Open Source Community
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/ismailkerimov/math-logic-mcp
8
+ Project-URL: Repository, https://github.com/ismailkerimov/math-logic-mcp
9
+ Project-URL: Bug Tracker, https://github.com/ismailkerimov/math-logic-mcp/issues
10
+ Keywords: mcp,llm,reasoning,symbolic,math,logic,proof,tool-calling
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: sympy>=1.12
22
+ Requires-Dist: z3-solver>=4.12.2
23
+ Requires-Dist: pydantic>=2.0
24
+ Requires-Dist: mcp[cli]>=1.0.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.4; extra == "dev"
27
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
29
+ Requires-Dist: black>=23.7; extra == "dev"
30
+ Requires-Dist: flake8>=6.0; extra == "dev"
31
+ Requires-Dist: mypy>=1.4; extra == "dev"
32
+ Requires-Dist: isort>=5.12; extra == "dev"
33
+ Provides-Extra: full
34
+ Requires-Dist: ortools>=9.7.2996; extra == "full"
35
+ Requires-Dist: litellm>=1.26.0; extra == "full"
36
+ Requires-Dist: redis>=5.0.0; extra == "full"
37
+ Requires-Dist: lark>=1.1; extra == "full"
38
+ Dynamic: license-file
39
+
40
+ # math-logic-mcp
41
+
42
+ **MCP server that gives small LLMs verified symbolic-math & logic tools.**
43
+
44
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
45
+
46
+ Small language models (Mistral, Llama, Phi, Gemma) struggle with multi-step math and formal logic. Instead of fine-tuning, **give them tools**. This project exposes a set of verified math and logic solvers via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), so any MCP-compatible LLM can call them as functions.
47
+
48
+ ## Features
49
+
50
+ | Tool | What it does | Backend |
51
+ |------|-------------|---------|
52
+ | `verify_arithmetic` | Safe arithmetic evaluation | Python stdlib (zero deps) |
53
+ | `solve_equation` | Symbolic equation solving | SymPy (optional) |
54
+ | `simplify_expression` | Simplify / factor / expand | SymPy (optional) |
55
+ | `compute_derivative` | Differentiation | SymPy (optional) |
56
+ | `compute_integral` | Integration | SymPy (optional) |
57
+ | `check_logic` | SAT / tautology / truth tables | Z3 (optional) |
58
+
59
+ Every result includes **proof steps** and **verification** — the LLM gets a machine-checked answer, not a guess.
60
+
61
+ ## Quick Start
62
+
63
+ ### Install (minimal — arithmetic only)
64
+
65
+ ```bash
66
+ pip install -e .
67
+ ```
68
+
69
+ ### Install (full — all solvers)
70
+
71
+ ```bash
72
+ pip install -e ".[full]"
73
+ ```
74
+
75
+ ### Run the MCP server
76
+
77
+ ```bash
78
+ # stdio transport (for Claude Desktop, Cursor, etc.)
79
+ math-logic-mcp
80
+
81
+ # HTTP/SSE transport (for remote clients)
82
+ math-logic-mcp --http
83
+ ```
84
+
85
+ ### Configure in Claude Desktop
86
+
87
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "math-logic": {
93
+ "command": "math-logic-mcp"
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ ### Configure in Cursor
100
+
101
+ Add to `.cursor/mcp.json`:
102
+
103
+ ```json
104
+ {
105
+ "mcpServers": {
106
+ "math-logic": {
107
+ "command": "math-logic-mcp"
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ ## Use as a Python Library
114
+
115
+ ```python
116
+ from math_logic import MathLogicEngine
117
+
118
+ engine = MathLogicEngine()
119
+
120
+ # Arithmetic (always available)
121
+ result = engine.solve("compute 2 + 3 * 4")
122
+ print(result.solutions) # ['14']
123
+
124
+ # Algebra (requires sympy)
125
+ result = engine.solve("Solve x^2 - 4 = 0")
126
+ print(result.solutions) # ['x = -2', 'x = 2']
127
+
128
+ # Logic (requires z3-solver)
129
+ result = engine.solve('Check satisfiability of "p and q"')
130
+ print(result.solutions) # ['Satisfiable: p=True, q=True']
131
+ ```
132
+
133
+ ## Architecture
134
+
135
+ ```
136
+ LLM ─── MCP Protocol ──▶ mcp_server.py
137
+
138
+ engine.py (router → solver → result)
139
+
140
+ ┌───────────────┼───────────────┐
141
+ ▼ ▼ ▼
142
+ ArithmeticSolver SymPySolver Z3Solver
143
+ (zero deps) (pip: sympy) (pip: z3-solver)
144
+ ```
145
+
146
+ The **router** classifies each problem by regex patterns and routes to the best available solver. Solvers are loaded lazily — if SymPy isn't installed, algebra problems gracefully report the missing dependency.
147
+
148
+ ## Installation Extras
149
+
150
+ | Extra | What it adds | Install size |
151
+ |-------|-------------|-------------|
152
+ | (none) | Arithmetic only | ~1 MB |
153
+ | `[sympy]` | + algebra, calculus, simplification | ~50 MB |
154
+ | `[z3]` | + propositional logic, SAT | ~30 MB |
155
+ | `[full]` | Everything | ~80 MB |
156
+ | `[dev]` | + pytest, ruff | ~85 MB |
157
+
158
+ ```bash
159
+ pip install -e ".[sympy]" # algebra + calculus
160
+ pip install -e ".[z3]" # logic
161
+ pip install -e ".[full]" # everything
162
+ pip install -e ".[full,dev]" # everything + dev tools
163
+ ```
164
+
165
+ ## Development
166
+
167
+ ```bash
168
+ git clone https://github.com/user/math-logic-mcp.git
169
+ cd math-logic-mcp
170
+ pip install -e ".[full,dev]"
171
+ pytest tests/ -v
172
+ ```
173
+
174
+ ## Docker
175
+
176
+ ```bash
177
+ docker build -t math-logic-mcp .
178
+ docker run -p 8080:8080 math-logic-mcp
179
+ ```
180
+
181
+ ## License
182
+
183
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,144 @@
1
+ # math-logic-mcp
2
+
3
+ **MCP server that gives small LLMs verified symbolic-math & logic tools.**
4
+
5
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
6
+
7
+ Small language models (Mistral, Llama, Phi, Gemma) struggle with multi-step math and formal logic. Instead of fine-tuning, **give them tools**. This project exposes a set of verified math and logic solvers via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), so any MCP-compatible LLM can call them as functions.
8
+
9
+ ## Features
10
+
11
+ | Tool | What it does | Backend |
12
+ |------|-------------|---------|
13
+ | `verify_arithmetic` | Safe arithmetic evaluation | Python stdlib (zero deps) |
14
+ | `solve_equation` | Symbolic equation solving | SymPy (optional) |
15
+ | `simplify_expression` | Simplify / factor / expand | SymPy (optional) |
16
+ | `compute_derivative` | Differentiation | SymPy (optional) |
17
+ | `compute_integral` | Integration | SymPy (optional) |
18
+ | `check_logic` | SAT / tautology / truth tables | Z3 (optional) |
19
+
20
+ Every result includes **proof steps** and **verification** — the LLM gets a machine-checked answer, not a guess.
21
+
22
+ ## Quick Start
23
+
24
+ ### Install (minimal — arithmetic only)
25
+
26
+ ```bash
27
+ pip install -e .
28
+ ```
29
+
30
+ ### Install (full — all solvers)
31
+
32
+ ```bash
33
+ pip install -e ".[full]"
34
+ ```
35
+
36
+ ### Run the MCP server
37
+
38
+ ```bash
39
+ # stdio transport (for Claude Desktop, Cursor, etc.)
40
+ math-logic-mcp
41
+
42
+ # HTTP/SSE transport (for remote clients)
43
+ math-logic-mcp --http
44
+ ```
45
+
46
+ ### Configure in Claude Desktop
47
+
48
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "math-logic": {
54
+ "command": "math-logic-mcp"
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### Configure in Cursor
61
+
62
+ Add to `.cursor/mcp.json`:
63
+
64
+ ```json
65
+ {
66
+ "mcpServers": {
67
+ "math-logic": {
68
+ "command": "math-logic-mcp"
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## Use as a Python Library
75
+
76
+ ```python
77
+ from math_logic import MathLogicEngine
78
+
79
+ engine = MathLogicEngine()
80
+
81
+ # Arithmetic (always available)
82
+ result = engine.solve("compute 2 + 3 * 4")
83
+ print(result.solutions) # ['14']
84
+
85
+ # Algebra (requires sympy)
86
+ result = engine.solve("Solve x^2 - 4 = 0")
87
+ print(result.solutions) # ['x = -2', 'x = 2']
88
+
89
+ # Logic (requires z3-solver)
90
+ result = engine.solve('Check satisfiability of "p and q"')
91
+ print(result.solutions) # ['Satisfiable: p=True, q=True']
92
+ ```
93
+
94
+ ## Architecture
95
+
96
+ ```
97
+ LLM ─── MCP Protocol ──▶ mcp_server.py
98
+
99
+ engine.py (router → solver → result)
100
+
101
+ ┌───────────────┼───────────────┐
102
+ ▼ ▼ ▼
103
+ ArithmeticSolver SymPySolver Z3Solver
104
+ (zero deps) (pip: sympy) (pip: z3-solver)
105
+ ```
106
+
107
+ The **router** classifies each problem by regex patterns and routes to the best available solver. Solvers are loaded lazily — if SymPy isn't installed, algebra problems gracefully report the missing dependency.
108
+
109
+ ## Installation Extras
110
+
111
+ | Extra | What it adds | Install size |
112
+ |-------|-------------|-------------|
113
+ | (none) | Arithmetic only | ~1 MB |
114
+ | `[sympy]` | + algebra, calculus, simplification | ~50 MB |
115
+ | `[z3]` | + propositional logic, SAT | ~30 MB |
116
+ | `[full]` | Everything | ~80 MB |
117
+ | `[dev]` | + pytest, ruff | ~85 MB |
118
+
119
+ ```bash
120
+ pip install -e ".[sympy]" # algebra + calculus
121
+ pip install -e ".[z3]" # logic
122
+ pip install -e ".[full]" # everything
123
+ pip install -e ".[full,dev]" # everything + dev tools
124
+ ```
125
+
126
+ ## Development
127
+
128
+ ```bash
129
+ git clone https://github.com/user/math-logic-mcp.git
130
+ cd math-logic-mcp
131
+ pip install -e ".[full,dev]"
132
+ pytest tests/ -v
133
+ ```
134
+
135
+ ## Docker
136
+
137
+ ```bash
138
+ docker build -t math-logic-mcp .
139
+ docker run -p 8080:8080 math-logic-mcp
140
+ ```
141
+
142
+ ## License
143
+
144
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,23 @@
1
+ """math-logic-mcp — MCP server with verified math & logic tools for LLMs."""
2
+
3
+ from math_logic.engine import (
4
+ MathLogicEngine,
5
+ SolveResult,
6
+ Proof,
7
+ ProofStep,
8
+ ProblemType,
9
+ SolverType,
10
+ BaseSolver,
11
+ )
12
+ from math_logic.router import Router
13
+
14
+ __all__ = [
15
+ "MathLogicEngine",
16
+ "SolveResult",
17
+ "Proof",
18
+ "ProofStep",
19
+ "ProblemType",
20
+ "SolverType",
21
+ "BaseSolver",
22
+ "Router",
23
+ ]