ngspice-mcp

ngspice-mcp

An MCP server for interfacing with the ngspice circuit simulator

gtnoble

Developer Tools
Visit Server

README

ngspice-mcp

A Model Context Protocol (MCP) server that provides access to ngspice circuit simulation functionality through a standardized protocol interface. This server enables AI language models to interact with ngspice in a controlled and structured way.

Features

  • Integration with ngspice's shared library interface
  • Standardized MCP protocol implementation
  • Synchronous operation with structured data access
  • Comprehensive output capture and redirection
  • Vector data handling with multiple representation formats
  • Support for both server and library usage modes
  • Built-in test suite

Requirements

  • D compiler (DMD/LDC)
  • ngspice shared library
  • MCP server library (d-mcp-server)
  • D build system (dub)

Installation

  1. Ensure system requirements are installed
  2. Clone the repository
  3. Build using dub:
dub build --config=server

Usage

The server can be started with:

./ngspice-mcp [options]

Command Line Options

  • --working-dir, -d: Set the working directory for circuit files (default: current directory)

Available Tools

Circuit Loading

  • loadCircuit: Load circuit netlists directly
  • loadNetlistFromFile: Load netlists from files

Example netlist:

RC Circuit
R1 in out 1k
C1 out 0 1u
.end

Simulation

  • runSimulation: Execute simulation commands

Common commands:

  • op: DC operating point
  • dc source start stop step
  • ac dec points fstart fend
  • tran step tstop

Data Access

  • getPlotNames: List available simulation plots
  • getVectorNames: List vectors in a specific plot
  • getVectorData: Retrieve vector data with options for:
    • Magnitude-phase representation
    • Rectangular (real-imaginary) representation
    • Both representations
    • Optional interval selection

Resources

  • stdout://: Standard output stream from ngspice
  • stderr://: Error output stream from ngspice
  • usage://: Comprehensive usage guide

Development

Project Structure

ngspice-mcp/
├── source/
│   ├── app.d           # Main application
│   ├── bindings/       # ngspice C API bindings
│   ├── database/       # SQLite database handling
│   ├── parser/         # Netlist parsing
│   └── server/         # MCP server implementation
├── resources/          # Resource files
└── bin/               # Build outputs

Build Configurations

  1. Server Mode
dub build --config=server
  1. Library Mode
dub build --config=library
  1. Unit Tests
dub test --config=unittest

Testing

Run the test suite:

dub test

Tests cover:

  • ngspice bindings
  • Server functionality
  • Tool validation
  • Resource handling
  • Error cases

Technical Details

Architecture

The server implements several key components:

  1. NgspiceServer: Core server implementation

    • Tool registration and handling
    • Resource management
    • Output stream capture
    • Vector data processing
  2. Output System

    • Stdout/stderr capture
    • Stream buffering
    • Resource notification
  3. Vector Processing

    • Complex number handling
    • Scientific notation formatting
    • Interval selection
    • Multiple representation formats

Database System

  • Model parameter storage
  • Efficient indexing and querying
  • Transaction support
  • Concurrent access handling

License

MIT License - see dub.json for details.

Copyright © 2024, Garret Noble

Contributing

Contributions are welcome! Please ensure:

  1. Code follows project style and standards
  2. Tests are included for new functionality
  3. Documentation is updated as needed
  4. Commit messages are clear and descriptive

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python