nsforge-mcp
Enables creation of new mathematical formulas through symbolic derivation, verification, and step-by-step control, leveraging SymPy for computation and storing results with provenance.
README
π₯ Neurosymbolic Forge (NSForge)
"Forge" = CREATE new formulas through verified derivation
π English | ηΉι«δΈζ
π¨ Core Concept: The "Forge"
NSForge is NOT a formula database β it's a derivation factory that CREATES new formulas.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β π¨ FORGE = Create new formulas through derivation β
β β
β Input: Base formulas Output: NEW derived formulas β
β βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββ β
β β β’ One-compartment β β Temperature-corrected elimination β β
β β β’ Arrhenius β βββ β Body fat-adjusted distribution β β
β β β’ Fick's law β β Renal function dose adjustment β β
β β β’ ... β β Custom PK/PD models β β
β βββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββ β
β (from sympy-mcp) (stored in NSForge) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β‘ Four Core Capabilities
| Capability | Description | Tools |
|---|---|---|
| DERIVE | Create new formulas by composing base formulas | substitute, simplify, differentiate, integrate |
| CONTROL | Full step control: review, edit, rollback, insert | get_step, update_step, rollback, delete_step, insert_note |
| VERIFY | Ensure correctness through multiple methods | check_dimensions, verify_derivative, symbolic_equal |
| STORE | Save derived formulas with full provenance | formulas/derivations/ repository |
π Ecosystem: Don't Reinvent the Wheel
<p align="center"> <img src="docs/images/architecture-overview.jpg" alt="NSForge Architecture and Ecosystem" width="700"> </p>
NSForge works WITH other MCP servers, not against them:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Scientific Computing Ecosystem β
β π’ 108 Tools Total π’ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β sympy-mcp (32 tools) β
β βββ Base formulas: F=ma, PV=nRT, Arrhenius... β
β βββ Physical constants: c, G, h, R... (SciPy CODATA) β
β βββ Symbolic computation engine (ODE, PDE, matrices) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β nsforge-mcp (76 tools) β YOU ARE HERE β
β βββ π¨ Derivation framework: compose, verify, generate code β
β βββ π Derivation repository: store CREATED formulas with provenance β
β βββ β
Verification layer: dimensional analysis, reverse verification β
β βββ π Formula search: Wikidata, BioModels, SciPy constants β
β βββ π Optimization bridge: prepare formulas for USolver β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β medical-calc-mcp (75+ tools) β
β βββ Clinical scores: APACHE, SOFA, GCS, MELD, qSOFA... β
β βββ Medical calculations: eGFR, IBW, BSA, MEWS... β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β usolver-mcp (Optional collaboration) β
β βββ π― Find optimal values for NSForge-derived formulas β
β βββ Solvers: Z3, OR-Tools, CVXPY, HiGHS β
β βββ Use case: dose optimization, circuit parameter selection β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
What NSForge stores:
| β BELONGS in NSForge | β Does NOT belong (use other tools) |
|---|---|
| Temperature-corrected drug elimination | Basic physics formulas (sympy-mcp) |
| Body fat-adjusted volume of distribution | Physical constants (sympy-mcp) |
| Renal function dose adjustments | Clinical scores (medical-calc-mcp) |
| Custom composite PK/PD models | Textbook formulas (references) |
π NSForge Unique Capabilities
<p align="center"> <img src="docs/images/nsforge-vs-sympy.jpg" alt="NSForge vs SymPy-MCP Unique Capabilities" width="700"> </p>
NSForge provides features not available in SymPy-MCP by directly leveraging SymPy modules:
| Feature | SymPy Module | Application | Status |
|---|---|---|---|
| Statistics & Probability | sympy.stats |
PopPK variability, uncertainty | β v0.2.1 |
| Limits & Series | sympy.limit, sympy.series |
Steady-state, accumulation | β v0.2.1 |
| Inequality Solving | sympy.solvers.inequalities |
Therapeutic window | β v0.2.1 |
| Assumption Queries | sympy.assumptions |
Auto-validation | β v0.2.1 |
| Advanced Algebra | sympy.expand/factor/apart... |
Expression manipulation | β v0.2.4 |
| Integral Transforms | sympy.laplace_transform/fourier_transform |
ODE solving, frequency analysis | β v0.2.4 |
| Derivation Workflow | NSForge exclusive | Step tracking, provenance | β Available |
| Verification Suite | NSForge exclusive | Dimension analysis | β Available |
π Details: See NSForge vs SymPy-MCP Comparison for complete analysis.
π¬ Workflow
<p align="center"> <img src="docs/images/derivation-workflow.jpg" alt="NSForge Derivation Workflow" width="700"> </p>
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β User Question NSForge Processing Pipeline β
β βββββββββββββ βββββββββββββββββββββββββββ β
β β
β "Drug concentration in 1οΈβ£ Query Formula Knowledge Base β
β a 38Β°C fever patient?" βββ ββ One-compartment PK: C(t) = CβΒ·e^(-kβt)
β ββ Arrhenius equation: k(T) = AΒ·e^(-Ea/RT)
β β
β 2οΈβ£ Compose Derivation β
β ββ Substitute k(T) into PK model β
β ββ Obtain temperature-corrected formulaβ
β β
β 3οΈβ£ Symbolic Computation (SymPy) β
β ββ C(t,T) = CβΒ·exp(-kβ,refΒ·tΒ·exp(...)) β
β β
β 4οΈβ£ Verify Results β
β ββ T=37Β°C reduces to standard model β β
β ββ Dimensional analysis passed β β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ποΈ Step-by-Step Control (NEW in v0.2.2)
NSForge now provides full CRUD control over derivation steps:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ποΈ STEP CONTROL - Navigate and Edit Your Derivation! β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Step 1 β Step 2 β Step 3 β Step 4 β Step 5 β Step 6 (current) β
β β β
β β β
β "Wait, step 3 looks wrong..." β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π READ β derivation_get_step(3) β View step details β β
β β βοΈ UPDATE β derivation_update_step(3, notes="...") β Fix notes β β
β β βͺ ROLLBACKβ derivation_rollback(2) β Return to step 2 β β
β β π INSERT β derivation_insert_note(2, "...") β Add explanation β β
β β ποΈ DELETE β derivation_delete_step(6) β Remove last step β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β After rollback: Step 1 β Step 2 (now current) β
β β Continue derivation from step 2, try a different path! β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Step CRUD Tools (5 new tools)
| Tool | Operation | Description |
|---|---|---|
derivation_get_step |
Read | Get details of any step (expression, notes, assumptions) |
derivation_update_step |
Update | Modify metadata (notes, assumptions, limitations) - NOT expression |
derivation_delete_step |
Delete | Remove the LAST step only (safety constraint) |
derivation_rollback |
Rollback | β‘ Jump back to any step, delete subsequent steps |
derivation_insert_note |
Insert | Add explanatory note at any position |
π‘ Key Insight: Expressions can't be edited directly (that would break verification). Use
rollbackto return to a valid state, then re-derive with corrections.
Use Cases
- Peer Review: "Step 5's assumption is questionable" β
update_step(5, notes="Validated for T<42Β°C only") - Wrong Path: "We should have used integration instead" β
rollback(3)β start fresh - Add Context: "Need to explain the Arrhenius substitution" β
insert_note(4, "Temperature effect on enzyme kinetics...") - Clean Up: "Last step was a mistake" β
delete_step(8)
π§ Why NSForge?
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β Problem: LLMs doing math directly β
β βββββββββββββββββββββββββββββββββ β
β β
β β May calculate wrong β Different results β Unverifiable β
β (hallucinations) each time β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β Solution: LLM + NSForge β
β βββββββββββββββββββββββ β
β β
β LLM handles: NSForge handles: β
β βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β β’ Understand query β β β’ Store verified β β
β β β’ Plan derivation β βββ β formulas β β
β β β’ Explain results β β β’ Precise symbolic β β
β βββββββββββββββββββββββ β computation β β
β "Understanding β β’ Track derivation β β
β & Planning" β sources β β
β β β’ Verify results β β
β βββββββββββββββββββββββ β
β "Computation β
β & Verification" β
β β
β β
Guaranteed correct β
Reproducible β
Fully traceable β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Derivation Repository Architecture
NSForge stores derived formulas with full provenance tracking:
formulas/
βββ derivations/ β All derived formulas go here
βββ README.md β Documentation
βββ pharmacokinetics/ β PK model derivations
βββ temp_corrected_elimination.md β Temperature-corrected k
βββ fat_adjusted_vd.md β Obesity-adjusted Vd
Each derivation result contains:
- LaTeX mathematical expression
- SymPy computable form
- Derived from: which base formulas were combined
- Derivation steps: the actual derivation process
- Verification status: dimensional analysis, limiting cases
- Clinical context and usage guidance
- YAML metadata for programmatic access
Example Derivations:
| Derivation | Domain | Description |
|---|---|---|
| Temperature-Corrected Elimination | PK | First-order elimination + Arrhenius temperature dependence |
| NPO Antibiotic Effect | PK/PD | Henderson-Hasselbalch + Emax model for pH-dependent absorption |
| Temperature-Corrected Michaelis-Menten | PK | Non-linear saturable kinetics with temperature effects |
| Cisatracurium Multiple Dosing | PK | Hydrolytic drug accumulation with temperature correction |
| Physiological Vd Body Composition | PK/PBPK | PBPK-based Vd adjustment for body composition (logP > 2) |
Example: NPO (Fasting) Impact on Antibiotic Efficacy
id: npo_antibiotic_effect
name: NPO Impact on Oral Antibiotic Efficacy
expression: E_0 + (E_max * C_eff^n) / (EC_50^n + C_eff^n)
where: C_eff = F_base * D / (Vd * (1 + 10^(pH - pKa)))
derived_from:
- henderson_hasselbalch # pH-dependent ionization
- emax_model # Pharmacodynamic effect
verified: true
verification_method: sympy_symbolic_substitution
clinical_context: |
Predicts reduced antibiotic efficacy in NPO patients due to
increased gastric pH. Critical for weak acid antibiotics like
Amoxicillin (pKa=2.4) where NPO can reduce effect by >90%.
See also: Python Implementation with clinical recommendations.
β¨ Features
| Category | Capabilities |
|---|---|
| π’ Symbolic Computation | Calculus, Algebra, Linear Algebra, ODE/PDE |
| π Formula Management | Storage, Query, Version Control, Source Tracking |
| π Derivation Composition | Multi-formula composition, Variable substitution, Condition modification |
| β Result Verification | Dimensional analysis, Boundary conditions, Reverse verification |
| π Code Generation | Generate Python functions from symbolic formulas |
π¦ Installation
Requirements
- Python 3.12+
- uv (recommended package manager)
# Using uv (recommended)
uv add nsforge-mcp
# Or using pip
pip install nsforge-mcp
From Source
git clone https://github.com/u9401066/nsforge-mcp.git
cd nsforge-mcp
# Create environment and install dependencies
uv sync --all-extras
# Verify installation
uv run python -c "import nsforge; print(nsforge.__version__)"
π Quick Start
As MCP Server
// Claude Desktop config (claude_desktop_config.json)
{
"mcpServers": {
"nsforge": {
"command": "uvx",
"args": ["nsforge-mcp"]
}
}
}
Usage Examples
Calculus computation:
User: Calculate β«(xΒ² + 3x)dx and verify the result
Agent calls NSForge:
β Result: xΒ³/3 + 3xΒ²/2 + C
β Verify: d/dx(xΒ³/3 + 3xΒ²/2) = xΒ² + 3x β
β Steps: Split integral β Power rule β Combine
Physics derivation:
User: Work done by ideal gas in isothermal expansion?
Agent calls NSForge:
β W = nRT ln(Vβ/Vβ)
β Derivation: PV=nRT β P=nRT/V β W=β«PdV β Integrate
Algorithm analysis:
User: Analyze T(n) = 2T(n/2) + n
Agent calls NSForge:
β T(n) = Ξ(n log n)
β Method: Master Theorem Case 2
β Example: Merge Sort
π Documentation
Design Documents
- Design Evolution: Derivation Framework - Architecture evolution from templates to composable derivation framework
- Domain Planning: Audio Circuits - Audio circuits principles and modifications
- Original Design - Complete architecture and API design (reference)
Example Derivations
- Power Amp Coupling Capacitor Design - Complete RC high-pass filter derivation
- From ideal formulas to practical considerations (output impedance, ESR, speaker impedance curve)
- Demonstrates NSForge "Principles + Modifications" framework in practice
API Reference
- API Reference - MCP tool documentation (TBD)
π οΈ MCP Tools
NSForge provides 75 MCP tools organized into 7 modules:
π₯ Derivation Engine (31 tools)
| Tool | Purpose |
|---|---|
derivation_start |
Start a new derivation session |
derivation_resume |
Resume a previous session |
derivation_list_sessions |
List all sessions |
derivation_status |
Get current session status |
derivation_show |
π Display current formula (like SymPy's print_latex_expression) |
derivation_load_formula |
Load base formulas |
derivation_substitute |
Variable substitution |
derivation_simplify |
Simplify expression |
derivation_solve_for |
Solve for variable |
derivation_differentiate |
Differentiate expression |
derivation_integrate |
Integrate expression |
derivation_record_step |
Record step with notes (β οΈ MUST display formula to user after!) |
derivation_add_note |
Add human insights |
derivation_get_steps |
Get all derivation steps |
derivation_get_step |
Get single step details |
derivation_update_step |
Update step metadata |
derivation_delete_step |
Delete last step |
derivation_rollback |
β‘ Rollback to any step |
derivation_insert_note |
Insert note at position |
derivation_complete |
Complete and save |
derivation_abort |
Abort current session |
derivation_list_saved |
List saved derivations |
derivation_get_saved |
Get saved derivation |
derivation_search_saved |
Search derivations |
derivation_repository_stats |
Repository statistics |
derivation_update_saved |
Update metadata |
derivation_delete_saved |
Delete derivation |
derivation_export_for_sympy |
π Export state to SymPy-MCP |
derivation_import_from_sympy |
π Import result from SymPy-MCP |
derivation_handoff_status |
π Check handoff capabilities |
derivation_prepare_for_optimization |
π Prepare for USolver |
β Verification (6 tools)
| Tool | Purpose |
|---|---|
verify_equality |
Verify two expressions are equal |
verify_derivative |
Verify derivative by integration |
verify_integral |
Verify integral by differentiation |
verify_solution |
Verify equation solution |
check_dimensions |
Dimensional analysis |
reverse_verify |
Reverse operation verification |
π’ Calculation (12 tools)
| Tool | Purpose |
|---|---|
calculate_limit |
Calculate limits |
calculate_series |
Taylor/Laurent series expansion |
calculate_summation |
Symbolic summation Ξ£ |
solve_inequality |
Solve single inequality |
solve_inequality_system |
Solve system of inequalities |
define_distribution |
Define probability distribution |
distribution_stats |
Get distribution statistics (mean, var, skew) |
distribution_probability |
Calculate probability P(condition) |
query_assumptions |
Query symbol assumptions |
refine_expression |
Refine expression with assumptions |
evaluate_numeric |
Numerical evaluation |
symbolic_equal |
Symbolic equality check |
π Expression (3 tools)
| Tool | Purpose |
|---|---|
parse_expression |
Parse mathematical expression |
validate_expression |
Validate expression syntax |
extract_symbols |
Extract symbols with metadata |
π» Code Generation (4 tools)
| Tool | Purpose |
|---|---|
generate_python_function |
Generate Python function |
generate_latex_derivation |
Generate LaTeX document |
generate_derivation_report |
Generate Markdown report |
generate_sympy_script |
Generate standalone SymPy script |
π’ Advanced Algebra (10 tools) - NEW in v0.2.4
| Tool | Purpose |
|---|---|
expand_expression |
Expand products: (x+1)Β² β xΒ²+2x+1 |
factor_expression |
Factorize: xΒ²-1 β (x-1)(x+1) |
collect_expression |
Collect terms by variable |
trigsimp_expression |
Trig simplify: sinΒ²+cosΒ² β 1 |
powsimp_expression |
Power simplify: xΒ²Β·xΒ³ β xβ΅ |
radsimp_expression |
Radical simplify |
combsimp_expression |
Factorial simplify: n!/(n-2)! β n(n-1) |
apart_expression |
π₯ Partial fractions (for inverse Laplace) |
cancel_expression |
Cancel common factors |
together_expression |
Combine fractions |
π Integral Transforms (4 tools) - NEW in v0.2.4
| Tool | Purpose |
|---|---|
laplace_transform_expression |
π₯ f(t) β F(s) for ODE solving |
inverse_laplace_transform_expression |
π₯ F(s) β f(t) multi-compartment PK |
fourier_transform_expression |
f(x) β F(k) frequency analysis |
inverse_fourier_transform_expression |
F(k) β f(x) signal reconstruction |
π Formula Search (6 tools) - NEW in v0.2.4
| Tool | Purpose |
|---|---|
formula_search |
π Unified search (Wikidata, BioModels, SciPy) |
formula_get |
π Get formula details by ID |
formula_categories |
π List available categories |
formula_pk_models |
π PK models (1/2-compartment, Michaelis-Menten) |
formula_kinetic_laws |
βοΈ Reaction kinetics (Hill, etc.) |
formula_constants |
π¬ Physical constants (from SciPy) |
π§ Agent Skills Architecture
NSForge includes 19 pre-built Skills that teach AI agents how to use the tools effectively:
π₯ NSForge-Specific Skills (6)
| Skill | Trigger Words | Description |
|---|---|---|
nsforge-derivation-workflow |
derive, ζ¨ε°, prove | Complete derivation workflow with session management |
nsforge-formula-management |
list, ε ¬εΌεΊ«, find formula | Query, update, delete saved formulas |
nsforge-formula-search |
Wikidata, BioModels, η©ηεΈΈζΈ | π Search external formula sources |
nsforge-verification-suite |
verify, check, ηΆεΊ¦ | Equality, derivative, integral, dimension checks |
nsforge-code-generation |
generate, export, LaTeX | Python functions, reports, SymPy scripts |
nsforge-quick-calculate |
calculate, simplify, solve | Quick calculations without session |
π§ General Development Skills (13)
Includes git-precommit, memory-updater, code-reviewer, test-generator, and more.
π Details: See NSForge Skills Guide for complete documentation.
Golden Rule: SymPy-MCP First!
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 1: SymPy-MCP executes computation β
β intro_many([...]) β introduce_expression(...) β β
β substitute/solve/dsolve... β print_latex_expression(...) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Phase 2: NSForge records & stores β
β derivation_record_step(...) β derivation_add_note(...) β β
β derivation_complete(...) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Division of Labor:
| Task | Tool | Reason |
|---|---|---|
| Math computation | SymPy-MCP | Full ODE/PDE/matrix capabilities |
| Formula display | print_latex_expression |
User confirmation at each step |
| Knowledge storage | NSForge | Provenance tracking, searchable |
| Dimension check | NSForge check_dimensions |
Physical unit verification |
ποΈ Project Structure
This project uses DDD (Domain-Driven Design) architecture with Core and MCP separation:
nsforge-mcp/
βββ .claude/skills/ # π§ Agent Skills (18 skills)
β βββ nsforge-derivation-workflow/ # Core workflow skill
β βββ nsforge-verification-suite/ # Verification skill
β βββ ... # 16 more skills
β
βββ src/
β βββ nsforge/ # π· Core Domain (pure logic, no MCP dependency)
β β βββ domain/ # Domain Layer
β β β βββ entities.py # - Entities (Expression, Derivation)
β β β βββ value_objects.py # - Value Objects (MathContext, Result)
β β β βββ services.py # - Domain service interfaces
β β βββ application/ # Application Layer
β β β βββ use_cases.py # - Use Cases (Calculate, Derive, Verify)
β β βββ infrastructure/ # Infrastructure Layer
β β βββ sympy_engine.py # - SymPy engine implementation
β β βββ verifier.py # - Verifier implementation
β β
β βββ nsforge_mcp/ # πΆ MCP Layer (Presentation)
β βββ server.py # - FastMCP Server
β βββ tools/ # - MCP tool definitions (76 tools)
β βββ derivation.py # - π₯ Derivation engine (31 tools)
β βββ calculate.py # - π’ Calculation (12 tools)
β βββ simplify.py # - π Advanced algebra (10+4 tools)
β βββ formula.py # - π Formula search (6 tools)
β βββ verify.py # - Verification (6 tools)
β βββ expression.py # - Expression parsing (3 tools)
β βββ codegen.py # - Code generation (4 tools)
β
βββ formulas/ # π Formula Repository
β βββ derivations/ # - Human-readable Markdown
β β βββ pharmacokinetics/ # - PK derivation examples
β βββ derived/ # - YAML metadata (auto-generated)
β
βββ derivation_sessions/ # πΎ Session persistence (JSON)
βββ docs/ # π Documentation
β βββ nsforge-skills-guide.md # - Skills usage guide (588 lines)
βββ examples/ # π Python examples
β βββ npo_antibiotic_analysis.py # Clinical application
β βββ physiological_vd_model.py # PBPK body composition model
βββ tests/ # Tests
βββ pyproject.toml # Project config (uv/hatch)
Architecture Benefits
- Core independently testable: No MCP dependency, can use
nsforgepackage standalone - MCP replaceable: Can support other protocols (REST, gRPC) in the future
- Dependency Inversion: Domain defines interfaces, Infrastructure implements
π§ͺ Development
# Clone
git clone https://github.com/u9401066/nsforge-mcp.git
cd nsforge-mcp
# Create environment (uv will automatically use Python 3.12+)
uv sync --all-extras
# Run tests
uv run pytest
# Code checks
uv run ruff check src/
uv run mypy src/
# Start dev server
uv run nsforge-mcp
π Collaboration with USolver (Optional)
NSForge can work with USolver to provide domain-expert formula derivation + mathematical optimization:
Workflow: NSForge β USolver
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Problem: Find optimal Fentanyl dose for 65yo patient with 30% BF, β
β concurrent midazolam, targeting 2.5 ng/mL at t=5min β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Step 1: NSForge derives modified formula β
β ββ Consider: CYP3A4 competition (-30% CL) β
β ββ Consider: Body fat 30% (+25% Vd) β
β ββ Consider: Age 65 (-15% CL) β
β ββ Output: C(t, dose) = dose/15.875 Γ exp(-0.476Γt/15.875) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Step 2: Prepare for optimization β
β ββ derivation_prepare_for_optimization() β
β β Variables: [dose], Parameters: {CL: 0.476, V1: 15.875} β
β β Constraints: dose β [0.01, 0.10], C(5) β [2.0, 4.0] β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Step 3: USolver finds optimal value β
β ββ usolver.solve(objective="C(5, dose) = 2.5", constraints=[...]) β
β β optimal_dose = 0.0354 mg (35.4 mcg) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why Combine?
| Tool | Strength | Output |
|---|---|---|
| NSForge | Domain knowledge (drug interactions, body composition) | Modified formula |
| USolver | Mathematical optimization (Z3, OR-Tools, CVXPY) | Optimal parameters |
| Together | Domain-smart + Math-precise | Best clinical decision |
Setup
- Install USolver:
uv run https://github.com/sdiehl/usolver/install.py - In NSForge, after completing derivation, call:
result = derivation_prepare_for_optimization() # Copy result.usolver_template to USolver - USolver returns optimal values
- Use optimal values in NSForge-derived formula for final calculation
π Skill:
.claude/skills/nsforge-usolver-collab/SKILL.md
π Roadmap
- [x] Design documents
- [x] MVP Implementation
- [x] Derivation Engine (26 tools)
- [x] SymPy Integration
- [x] Verification Suite (6 tools)
- [x] MCP Server
- [x] Step Control System (v0.2.2)
- [x] Read/Update/Delete steps
- [x] Rollback to any point
- [x] Insert notes at any position
- [x] Agent Skills System
- [x] 6 NSForge-specific workflows
- [x] 13 general development skills
- [x] Skills documentation
- [x] Advanced Algebra & Transforms (v0.2.4)
- [x] 10 simplification tools (expand, factor, apart...)
- [x] 4 integral transforms (Laplace, Fourier)
- [x] SymPy coverage: 85% β 92%
- [x] External Formula Search (v0.2.4)
- [x] Wikidata SPARQL adapter
- [x] BioModels adapter
- [x] SciPy constants
- [x] Pharmacokinetics Domain
- [x] Temperature-corrected elimination
- [x] NPO antibiotic effect model
- [x] Michaelis-Menten with temperature
- [x] Multiple dosing accumulation
- [ ] Domain Expansion
- [ ] Physics formula library
- [ ] Audio circuits (in progress)
- [ ] Algorithm analysis
- [ ] Advanced Features
- [ ] Lean4 formal verification
- [ ] Automatic derivation planning
π€ Contributing
Contributions welcome! Please see CONTRIBUTING.md.
π License
NSForge β Forge new formulas through verified derivation | Where Neural Meets Symbolic
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.