Cover image
Try Now
2025-04-14

用于与NGSpice电路模拟器接口的MCP服务器

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

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

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • chongdashu
  • 使用模型上下文协议(MCP),启用Cursor,Windsurf和Claude Desktop等AI助手客户,以通过自然语言控制虚幻引擎。

    Reviews

    2 (1)
    Avatar
    user_F89qS5MO
    2025-04-17

    I've been using ngspice-mcp for a while now, and it’s simply amazing! This tool by gtnoble is a must-have for anyone working with spice simulations. It's user-friendly and tremendously enhances productivity. Check it out on GitHub for an incredible experience!