kicad-sch-api 0.1.6__py3-none-any.whl → 0.2.0__py3-none-any.whl
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.
Potentially problematic release.
This version of kicad-sch-api might be problematic. Click here for more details.
- kicad_sch_api/cli.py +64 -222
- {kicad_sch_api-0.1.6.dist-info → kicad_sch_api-0.2.0.dist-info}/METADATA +32 -43
- {kicad_sch_api-0.1.6.dist-info → kicad_sch_api-0.2.0.dist-info}/RECORD +7 -9
- {kicad_sch_api-0.1.6.dist-info → kicad_sch_api-0.2.0.dist-info}/entry_points.txt +0 -1
- kicad_sch_api/mcp/__init__.py +0 -7
- kicad_sch_api/mcp/server.py +0 -1511
- {kicad_sch_api-0.1.6.dist-info → kicad_sch_api-0.2.0.dist-info}/WHEEL +0 -0
- {kicad_sch_api-0.1.6.dist-info → kicad_sch_api-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {kicad_sch_api-0.1.6.dist-info → kicad_sch_api-0.2.0.dist-info}/top_level.txt +0 -0
kicad_sch_api/cli.py
CHANGED
|
@@ -2,85 +2,44 @@
|
|
|
2
2
|
"""
|
|
3
3
|
KiCAD Schematic API - Command Line Interface
|
|
4
4
|
|
|
5
|
-
Provides helpful commands for
|
|
5
|
+
Provides helpful commands for testing and usage of the library.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import sys
|
|
9
|
-
import json
|
|
10
|
-
import os
|
|
11
9
|
import subprocess
|
|
12
10
|
import argparse
|
|
13
11
|
from pathlib import Path
|
|
14
|
-
from typing import Dict, Any
|
|
15
12
|
|
|
16
|
-
def get_claude_config_path() -> Path:
|
|
17
|
-
"""Get the Claude Code configuration file path for current platform."""
|
|
18
|
-
if sys.platform == "darwin":
|
|
19
|
-
return Path.home() / "Library/Application Support/Claude/claude_desktop_config.json"
|
|
20
|
-
elif sys.platform == "win32":
|
|
21
|
-
return Path(os.environ["APPDATA"]) / "Claude/claude_desktop_config.json"
|
|
22
|
-
else: # Linux and others
|
|
23
|
-
return Path.home() / ".config/Claude/claude_desktop_config.json"
|
|
24
|
-
|
|
25
|
-
def setup_claude_code() -> bool:
|
|
26
|
-
"""Automatically configure Claude Code MCP settings."""
|
|
27
|
-
print("🔧 Setting up Claude Code MCP configuration...")
|
|
28
|
-
|
|
29
|
-
config_path = get_claude_config_path()
|
|
30
|
-
|
|
31
|
-
# Create directory if it doesn't exist
|
|
32
|
-
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
33
|
-
|
|
34
|
-
# Backup existing config
|
|
35
|
-
if config_path.exists():
|
|
36
|
-
backup_path = config_path.with_suffix(f".backup.{config_path.stat().st_mtime:.0f}.json")
|
|
37
|
-
backup_path.write_text(config_path.read_text())
|
|
38
|
-
print(f"📁 Backed up existing config to: {backup_path}")
|
|
39
|
-
|
|
40
|
-
# Read existing config or create new one
|
|
41
|
-
if config_path.exists():
|
|
42
|
-
with open(config_path) as f:
|
|
43
|
-
config = json.load(f)
|
|
44
|
-
else:
|
|
45
|
-
config = {}
|
|
46
|
-
|
|
47
|
-
# Ensure mcpServers section exists
|
|
48
|
-
if "mcpServers" not in config:
|
|
49
|
-
config["mcpServers"] = {}
|
|
50
|
-
|
|
51
|
-
# Use direct Python command - this is more reliable than trying to find binary paths
|
|
52
|
-
config["mcpServers"]["kicad-sch-api"] = {
|
|
53
|
-
"command": sys.executable,
|
|
54
|
-
"args": ["-m", "kicad_sch_api.mcp.server"],
|
|
55
|
-
"env": {}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# Write configuration
|
|
59
|
-
with open(config_path, 'w') as f:
|
|
60
|
-
json.dump(config, f, indent=2)
|
|
61
|
-
|
|
62
|
-
print(f"✅ Configuration written to: {config_path}")
|
|
63
|
-
print("🔄 Please restart Claude Code to apply changes")
|
|
64
|
-
return True
|
|
65
13
|
|
|
66
14
|
def test_installation() -> bool:
|
|
67
|
-
"""Test that the
|
|
68
|
-
print("🧪 Testing KiCAD Schematic
|
|
15
|
+
"""Test that the library is working correctly."""
|
|
16
|
+
print("🧪 Testing KiCAD Schematic API Library...")
|
|
69
17
|
|
|
70
18
|
try:
|
|
71
|
-
# Test import
|
|
72
|
-
|
|
73
|
-
|
|
19
|
+
# Test basic import
|
|
20
|
+
import kicad_sch_api
|
|
21
|
+
version = getattr(kicad_sch_api, '__version__', 'unknown')
|
|
22
|
+
print(f"✅ Library imports successfully: v{version}")
|
|
74
23
|
|
|
75
|
-
# Test
|
|
76
|
-
|
|
77
|
-
|
|
24
|
+
# Test core functionality
|
|
25
|
+
import kicad_sch_api as ksa
|
|
26
|
+
sch = ksa.create_schematic("test")
|
|
27
|
+
print("✅ Can create schematic")
|
|
28
|
+
|
|
29
|
+
# Test component addition
|
|
30
|
+
sch.components.add(
|
|
31
|
+
lib_id="Device:R",
|
|
32
|
+
reference="R1",
|
|
33
|
+
value="10k",
|
|
34
|
+
position=(100, 100)
|
|
35
|
+
)
|
|
36
|
+
print("✅ Can add components")
|
|
78
37
|
|
|
79
|
-
# Test
|
|
38
|
+
# Test library access
|
|
80
39
|
from kicad_sch_api.library.cache import get_symbol_cache
|
|
81
40
|
cache = get_symbol_cache()
|
|
82
41
|
stats = cache.get_performance_stats()
|
|
83
|
-
print(f"✅ Symbol cache
|
|
42
|
+
print(f"✅ Symbol cache available: {stats['total_symbols_cached']} symbols")
|
|
84
43
|
|
|
85
44
|
print("🎉 All tests passed!")
|
|
86
45
|
return True
|
|
@@ -89,72 +48,21 @@ def test_installation() -> bool:
|
|
|
89
48
|
print(f"❌ Test failed: {e}")
|
|
90
49
|
return False
|
|
91
50
|
|
|
51
|
+
|
|
92
52
|
def show_status() -> bool:
|
|
93
|
-
"""Show current installation
|
|
94
|
-
print("📊 KiCAD Schematic
|
|
53
|
+
"""Show current installation status."""
|
|
54
|
+
print("📊 KiCAD Schematic API Library Status")
|
|
95
55
|
print("=" * 40)
|
|
96
56
|
|
|
97
57
|
# Check installation
|
|
98
58
|
try:
|
|
99
59
|
import kicad_sch_api
|
|
100
60
|
version = getattr(kicad_sch_api, '__version__', 'unknown')
|
|
101
|
-
print(f"✅
|
|
61
|
+
print(f"✅ Library installed: v{version}")
|
|
102
62
|
except ImportError:
|
|
103
|
-
print("❌
|
|
63
|
+
print("❌ Library not installed")
|
|
104
64
|
return False
|
|
105
65
|
|
|
106
|
-
# Check MCP command
|
|
107
|
-
mcp_cmd_path = None
|
|
108
|
-
try:
|
|
109
|
-
result = subprocess.run(['kicad-sch-mcp', '--help'],
|
|
110
|
-
capture_output=True, timeout=5)
|
|
111
|
-
if result.returncode == 0:
|
|
112
|
-
print("✅ MCP command available")
|
|
113
|
-
mcp_cmd_path = "kicad-sch-mcp"
|
|
114
|
-
else:
|
|
115
|
-
print("⚠️ MCP command found but returns error")
|
|
116
|
-
except (subprocess.TimeoutExpired, FileNotFoundError):
|
|
117
|
-
# Try to find the command in common locations
|
|
118
|
-
import sys
|
|
119
|
-
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
120
|
-
possible_paths = [
|
|
121
|
-
f"/Library/Frameworks/Python.framework/Versions/{python_version}/bin/kicad-sch-mcp",
|
|
122
|
-
os.path.expanduser(f"~/Library/Python/{python_version}/bin/kicad-sch-mcp"),
|
|
123
|
-
os.path.expanduser("~/.local/bin/kicad-sch-mcp"),
|
|
124
|
-
"/usr/local/bin/kicad-sch-mcp"
|
|
125
|
-
]
|
|
126
|
-
|
|
127
|
-
for path_to_try in possible_paths:
|
|
128
|
-
if os.path.exists(path_to_try) and os.access(path_to_try, os.X_OK):
|
|
129
|
-
print(f"✅ MCP command found at: {path_to_try}")
|
|
130
|
-
print("⚠️ Note: Command not in PATH, but found at above location")
|
|
131
|
-
mcp_cmd_path = path_to_try
|
|
132
|
-
break
|
|
133
|
-
|
|
134
|
-
if not mcp_cmd_path:
|
|
135
|
-
print("❌ MCP command not found in PATH")
|
|
136
|
-
print(" You may need to add Python scripts directory to your PATH")
|
|
137
|
-
print(f" Try: export PATH=\"/Library/Frameworks/Python.framework/Versions/{python_version}/bin:$PATH\"")
|
|
138
|
-
|
|
139
|
-
# Store found path for potential use in configuration
|
|
140
|
-
if mcp_cmd_path:
|
|
141
|
-
os.environ['FOUND_MCP_PATH'] = mcp_cmd_path
|
|
142
|
-
|
|
143
|
-
# Check Claude Code configuration
|
|
144
|
-
config_path = get_claude_config_path()
|
|
145
|
-
if config_path.exists():
|
|
146
|
-
try:
|
|
147
|
-
with open(config_path) as f:
|
|
148
|
-
config = json.load(f)
|
|
149
|
-
if "kicad-sch-api" in config.get("mcpServers", {}):
|
|
150
|
-
print("✅ Claude Code MCP configuration found")
|
|
151
|
-
else:
|
|
152
|
-
print("⚠️ Claude Code config exists but kicad-sch-api not configured")
|
|
153
|
-
except json.JSONDecodeError:
|
|
154
|
-
print("❌ Claude Code config file is invalid JSON")
|
|
155
|
-
else:
|
|
156
|
-
print("❌ Claude Code configuration not found")
|
|
157
|
-
|
|
158
66
|
# Check KiCAD libraries
|
|
159
67
|
try:
|
|
160
68
|
from kicad_sch_api.library.cache import get_symbol_cache
|
|
@@ -166,6 +74,7 @@ def show_status() -> bool:
|
|
|
166
74
|
|
|
167
75
|
return True
|
|
168
76
|
|
|
77
|
+
|
|
169
78
|
def create_demo() -> bool:
|
|
170
79
|
"""Create a demo schematic to test functionality."""
|
|
171
80
|
print("🎨 Creating demo schematic...")
|
|
@@ -181,23 +90,11 @@ def create_demo() -> bool:
|
|
|
181
90
|
capacitor = sch.components.add('Device:C', reference='C1', value='100nF', position=(150, 100))
|
|
182
91
|
led = sch.components.add('Device:LED', reference='D1', value='LED', position=(200, 100))
|
|
183
92
|
|
|
184
|
-
# Add a hierarchical sheet
|
|
185
|
-
sheet_uuid = sch.add_sheet(
|
|
186
|
-
name="Subcircuit",
|
|
187
|
-
filename="subcircuit_demo.kicad_sch",
|
|
188
|
-
position=(100, 150),
|
|
189
|
-
size=(60, 40)
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
# Add sheet pins
|
|
193
|
-
sch.add_sheet_pin(sheet_uuid, "VCC", "input", (0, 10))
|
|
194
|
-
sch.add_sheet_pin(sheet_uuid, "GND", "input", (0, 30))
|
|
195
|
-
|
|
196
93
|
# Save schematic
|
|
197
94
|
sch.save("demo_circuit.kicad_sch")
|
|
198
95
|
|
|
199
96
|
print("✅ Demo schematic created: demo_circuit.kicad_sch")
|
|
200
|
-
print("📁 Contains: resistor, capacitor,
|
|
97
|
+
print("📁 Contains: resistor, capacitor, and LED")
|
|
201
98
|
print("🔗 Try opening in KiCAD: kicad demo_circuit.kicad_sch")
|
|
202
99
|
|
|
203
100
|
return True
|
|
@@ -206,6 +103,7 @@ def create_demo() -> bool:
|
|
|
206
103
|
print(f"❌ Demo creation failed: {e}")
|
|
207
104
|
return False
|
|
208
105
|
|
|
106
|
+
|
|
209
107
|
def init_cache() -> bool:
|
|
210
108
|
"""Initialize the component discovery cache."""
|
|
211
109
|
print("🔄 Initializing component discovery cache...")
|
|
@@ -219,6 +117,7 @@ def init_cache() -> bool:
|
|
|
219
117
|
print(f"❌ Cache initialization failed: {e}")
|
|
220
118
|
return False
|
|
221
119
|
|
|
120
|
+
|
|
222
121
|
def check_kicad() -> bool:
|
|
223
122
|
"""Check KiCAD installation and library access."""
|
|
224
123
|
print("🔍 Checking KiCAD installation...")
|
|
@@ -250,74 +149,21 @@ def check_kicad() -> bool:
|
|
|
250
149
|
print(f"❌ Library access failed: {e}")
|
|
251
150
|
return False
|
|
252
151
|
|
|
253
|
-
def show_logs():
|
|
254
|
-
"""Show recent MCP server logs."""
|
|
255
|
-
print("📜 Recent MCP Server Logs")
|
|
256
|
-
print("=" * 25)
|
|
257
|
-
|
|
258
|
-
# For now, just run the server with debug output
|
|
259
|
-
print("To view live logs, run:")
|
|
260
|
-
print(" kicad-sch-mcp --debug")
|
|
261
|
-
print()
|
|
262
|
-
print("Or check Claude Code logs in:")
|
|
263
|
-
if sys.platform == "darwin":
|
|
264
|
-
print(" ~/Library/Logs/Claude/mcp-server-kicad-sch-api.log")
|
|
265
|
-
elif sys.platform == "win32":
|
|
266
|
-
print(" %USERPROFILE%\\AppData\\Local\\Claude\\Logs\\mcp-server-kicad-sch-api.log")
|
|
267
|
-
else:
|
|
268
|
-
print(" ~/.local/share/Claude/logs/mcp-server-kicad-sch-api.log")
|
|
269
152
|
|
|
270
|
-
def
|
|
271
|
-
"""
|
|
272
|
-
print("
|
|
273
|
-
print("=" *
|
|
274
|
-
print()
|
|
275
|
-
|
|
276
|
-
success = True
|
|
277
|
-
|
|
278
|
-
# 1. Test installation
|
|
279
|
-
print("Step 1/4: Testing installation...")
|
|
280
|
-
if not test_installation():
|
|
281
|
-
print("❌ Installation test failed. Please reinstall the package.")
|
|
282
|
-
return False
|
|
283
|
-
print()
|
|
284
|
-
|
|
285
|
-
# 2. Initialize cache
|
|
286
|
-
print("Step 2/4: Initializing component cache...")
|
|
287
|
-
if not init_cache():
|
|
288
|
-
print("⚠️ Cache initialization failed, but continuing...")
|
|
289
|
-
print()
|
|
290
|
-
|
|
291
|
-
# 3. Setup Claude Code (using direct Python command)
|
|
292
|
-
print("Step 3/4: Configuring Claude Code...")
|
|
293
|
-
if not setup_claude_code():
|
|
294
|
-
print("⚠️ Claude Code setup failed, but continuing...")
|
|
295
|
-
print()
|
|
296
|
-
|
|
297
|
-
# 4. Create demo
|
|
298
|
-
print("Step 4/4: Creating demo schematic...")
|
|
299
|
-
if not create_demo():
|
|
300
|
-
print("⚠️ Demo creation failed, but setup is complete")
|
|
301
|
-
print()
|
|
302
|
-
|
|
303
|
-
# Final status
|
|
304
|
-
print("🎉 Setup Complete!")
|
|
305
|
-
print()
|
|
306
|
-
print("✅ What was configured:")
|
|
307
|
-
print(" • MCP server ready for Claude Code")
|
|
308
|
-
print(" • Component discovery cache initialized")
|
|
309
|
-
print(" • Demo schematic created")
|
|
153
|
+
def show_mcp_info() -> None:
|
|
154
|
+
"""Show information about MCP server integration."""
|
|
155
|
+
print("🤖 MCP Server Integration")
|
|
156
|
+
print("=" * 25)
|
|
310
157
|
print()
|
|
311
|
-
print("
|
|
312
|
-
print("
|
|
313
|
-
print("2. Try: 'Create a voltage divider with two 10kΩ resistors'")
|
|
314
|
-
print("3. Open demo_circuit.kicad_sch in KiCAD to see the example")
|
|
158
|
+
print("This library serves as a foundation for MCP servers.")
|
|
159
|
+
print("For AI agent integration, install the dedicated MCP server:")
|
|
315
160
|
print()
|
|
316
|
-
print("
|
|
317
|
-
print("
|
|
161
|
+
print(" pip install mcp-kicad-sch-api")
|
|
162
|
+
print(" code mcp install mcp-kicad-sch-api")
|
|
318
163
|
print()
|
|
319
|
-
|
|
320
|
-
|
|
164
|
+
print("Related projects:")
|
|
165
|
+
print(" • mcp-kicad-sch-api: https://github.com/circuit-synth/mcp-kicad-sch-api")
|
|
166
|
+
print(" • Claude Code: https://claude.ai/code")
|
|
321
167
|
|
|
322
168
|
|
|
323
169
|
def main():
|
|
@@ -327,55 +173,50 @@ def main():
|
|
|
327
173
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
328
174
|
epilog="""
|
|
329
175
|
Examples:
|
|
330
|
-
kicad-sch-api --
|
|
331
|
-
kicad-sch-api --setup-claude-code # Configure Claude Code MCP settings only
|
|
332
|
-
kicad-sch-api --test # Test installation
|
|
176
|
+
kicad-sch-api --test # Test library installation
|
|
333
177
|
kicad-sch-api --demo # Create demo schematic
|
|
178
|
+
kicad-sch-api --status # Show library status
|
|
334
179
|
"""
|
|
335
180
|
)
|
|
336
181
|
|
|
337
|
-
# Main
|
|
338
|
-
parser.add_argument('--setup', action='store_true',
|
|
339
|
-
help='Complete one-command setup (RECOMMENDED)')
|
|
340
|
-
|
|
341
|
-
# Setup options
|
|
342
|
-
parser.add_argument('--setup-claude-code', action='store_true',
|
|
343
|
-
help='Configure Claude Code MCP settings only')
|
|
182
|
+
# Main options
|
|
344
183
|
parser.add_argument('--test', action='store_true',
|
|
345
|
-
help='Test that the
|
|
184
|
+
help='Test that the library is working')
|
|
346
185
|
parser.add_argument('--status', action='store_true',
|
|
347
|
-
help='Show
|
|
186
|
+
help='Show library installation status')
|
|
348
187
|
parser.add_argument('--demo', action='store_true',
|
|
349
188
|
help='Create a demo schematic')
|
|
350
189
|
parser.add_argument('--init-cache', action='store_true',
|
|
351
190
|
help='Initialize component discovery cache')
|
|
352
191
|
parser.add_argument('--check-kicad', action='store_true',
|
|
353
192
|
help='Check KiCAD installation and libraries')
|
|
354
|
-
parser.add_argument('--
|
|
355
|
-
help='Show
|
|
193
|
+
parser.add_argument('--mcp-info', action='store_true',
|
|
194
|
+
help='Show MCP server integration information')
|
|
356
195
|
|
|
357
196
|
args = parser.parse_args()
|
|
358
197
|
|
|
359
|
-
# If no arguments provided,
|
|
198
|
+
# If no arguments provided, show help
|
|
360
199
|
if not any(vars(args).values()):
|
|
361
200
|
print("🚀 KiCAD Schematic API - Command Line Interface")
|
|
362
201
|
print()
|
|
363
|
-
print("
|
|
364
|
-
print(
|
|
202
|
+
print("This is a pure Python library for KiCAD schematic manipulation.")
|
|
203
|
+
print()
|
|
204
|
+
print("🧪 Test the installation:")
|
|
205
|
+
print(" kicad-sch-api --test")
|
|
206
|
+
print()
|
|
207
|
+
print("🎨 Create a demo schematic:")
|
|
208
|
+
print(" kicad-sch-api --demo")
|
|
209
|
+
print()
|
|
210
|
+
print("🤖 For AI agent integration:")
|
|
211
|
+
print(" kicad-sch-api --mcp-info")
|
|
365
212
|
print()
|
|
366
|
-
print("🆘 For
|
|
213
|
+
print("🆘 For all options:")
|
|
367
214
|
print(" kicad-sch-api --help")
|
|
368
215
|
return
|
|
369
216
|
|
|
370
217
|
# Execute requested actions
|
|
371
218
|
success = True
|
|
372
219
|
|
|
373
|
-
if args.setup:
|
|
374
|
-
success &= setup_everything()
|
|
375
|
-
|
|
376
|
-
if args.setup_claude_code:
|
|
377
|
-
success &= setup_claude_code()
|
|
378
|
-
|
|
379
220
|
if args.test:
|
|
380
221
|
success &= test_installation()
|
|
381
222
|
|
|
@@ -391,10 +232,11 @@ Examples:
|
|
|
391
232
|
if args.check_kicad:
|
|
392
233
|
success &= check_kicad()
|
|
393
234
|
|
|
394
|
-
if args.
|
|
395
|
-
|
|
235
|
+
if args.mcp_info:
|
|
236
|
+
show_mcp_info()
|
|
396
237
|
|
|
397
238
|
sys.exit(0 if success else 1)
|
|
398
239
|
|
|
240
|
+
|
|
399
241
|
if __name__ == "__main__":
|
|
400
242
|
main()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kicad-sch-api
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Professional KiCAD schematic manipulation library with exact format preservation
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Professional KiCAD schematic manipulation library with exact format preservation
|
|
5
5
|
Author-email: Circuit-Synth <shane@circuit-synth.com>
|
|
6
6
|
Maintainer-email: Circuit-Synth <shane@circuit-synth.com>
|
|
7
7
|
License-Expression: MIT
|
|
@@ -25,8 +25,6 @@ Classifier: Operating System :: OS Independent
|
|
|
25
25
|
Requires-Python: >=3.10
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
License-File: LICENSE
|
|
28
|
-
Requires-Dist: fastmcp>=2.0.0
|
|
29
|
-
Requires-Dist: mcp[cli]>=1.13.0
|
|
30
28
|
Requires-Dist: sexpdata>=0.0.3
|
|
31
29
|
Requires-Dist: typing-extensions>=4.0.0; python_version < "3.11"
|
|
32
30
|
Provides-Extra: dev
|
|
@@ -38,9 +36,6 @@ Requires-Dist: isort>=5.0.0; extra == "dev"
|
|
|
38
36
|
Requires-Dist: flake8>=4.0.0; extra == "dev"
|
|
39
37
|
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
40
38
|
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
41
|
-
Provides-Extra: mcp
|
|
42
|
-
Requires-Dist: mcp[cli]>=1.0.0; extra == "mcp"
|
|
43
|
-
Requires-Dist: fastmcp>=2.0.0; extra == "mcp"
|
|
44
39
|
Provides-Extra: docs
|
|
45
40
|
Requires-Dist: sphinx>=5.0.0; extra == "docs"
|
|
46
41
|
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
|
|
@@ -173,20 +168,28 @@ netlist = sch.generate_netlist()
|
|
|
173
168
|
net_info = netlist.analyze_net("VCC")
|
|
174
169
|
```
|
|
175
170
|
|
|
176
|
-
## 🤖 AI Agent Integration
|
|
171
|
+
## 🤖 AI Agent Integration
|
|
177
172
|
|
|
178
|
-
|
|
173
|
+
This library serves as the foundational layer for AI agent integration through dedicated MCP (Model Context Protocol) servers.
|
|
179
174
|
|
|
180
|
-
###
|
|
175
|
+
### MCP Server Integration
|
|
181
176
|
|
|
182
177
|
```bash
|
|
183
|
-
# Install MCP server
|
|
184
|
-
pip install kicad-sch-api
|
|
178
|
+
# Install the dedicated MCP server (separate package)
|
|
179
|
+
pip install mcp-kicad-sch-api
|
|
185
180
|
|
|
186
|
-
# Configure for Claude Code
|
|
187
|
-
kicad-sch-api
|
|
181
|
+
# Configure for Claude Code
|
|
182
|
+
code mcp install mcp-kicad-sch-api
|
|
188
183
|
```
|
|
189
184
|
|
|
185
|
+
### Library Design for MCP Compatibility
|
|
186
|
+
|
|
187
|
+
This library is specifically designed to provide:
|
|
188
|
+
- **Stable API**: Consistent interface for MCP servers to build upon
|
|
189
|
+
- **Format Preservation**: Guaranteed exact KiCAD output for reliable automation
|
|
190
|
+
- **Professional Validation**: Component and library validation for quality assurance
|
|
191
|
+
- **Performance**: Optimized for AI agent workloads with caching and bulk operations
|
|
192
|
+
|
|
190
193
|
### Usage with AI Agents
|
|
191
194
|
|
|
192
195
|
```
|
|
@@ -196,23 +199,8 @@ kicad-sch-api --setup-claude-code
|
|
|
196
199
|
"Generate a hierarchical schematic with power supply subcircuit"
|
|
197
200
|
```
|
|
198
201
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
2. Use hierarchical labels instead of messy wires
|
|
202
|
-
3. Apply KiCAD design best practices automatically
|
|
203
|
-
4. Generate clean, industry-standard layouts
|
|
204
|
-
|
|
205
|
-
### Available MCP Tools
|
|
206
|
-
|
|
207
|
-
| Tool | Description |
|
|
208
|
-
|------|-------------|
|
|
209
|
-
| `create_schematic` | Create new schematic files |
|
|
210
|
-
| `add_component` | Add components with validation |
|
|
211
|
-
| `search_components` | Find components in KiCAD libraries |
|
|
212
|
-
| `add_hierarchical_sheet` | Create multi-sheet designs |
|
|
213
|
-
| `validate_component` | Check component/footprint compatibility |
|
|
214
|
-
| `list_components` | Get all components in schematic |
|
|
215
|
-
| `save_schematic` | Save with exact format preservation |
|
|
202
|
+
**Related MCP Servers:**
|
|
203
|
+
- **[mcp-kicad-sch-api](https://github.com/circuit-synth/mcp-kicad-sch-api)**: Full-featured MCP server built on this library
|
|
216
204
|
|
|
217
205
|
## 🏗️ Architecture
|
|
218
206
|
|
|
@@ -223,7 +211,6 @@ kicad_sch_api/
|
|
|
223
211
|
├── core/ # Core schematic manipulation
|
|
224
212
|
├── library/ # KiCAD library integration
|
|
225
213
|
├── integration/ # KiCAD CLI and tool integration
|
|
226
|
-
├── mcp/ # MCP server for AI agents
|
|
227
214
|
└── utils/ # Validation and utilities
|
|
228
215
|
```
|
|
229
216
|
|
|
@@ -232,7 +219,7 @@ kicad_sch_api/
|
|
|
232
219
|
- **Building Block First**: Designed to be the foundation for other tools
|
|
233
220
|
- **Exact Format Preservation**: Guaranteed byte-perfect KiCAD output
|
|
234
221
|
- **Professional Quality**: Comprehensive error handling and validation
|
|
235
|
-
- **
|
|
222
|
+
- **MCP Foundation**: Designed as a stable foundation for MCP servers and AI agents
|
|
236
223
|
- **Performance Optimized**: Fast operations on large schematics
|
|
237
224
|
|
|
238
225
|
## 🧪 Testing & Quality
|
|
@@ -266,26 +253,27 @@ uv run flake8 kicad_sch_api/ tests/
|
|
|
266
253
|
|
|
267
254
|
## 🔗 Ecosystem
|
|
268
255
|
|
|
269
|
-
This library
|
|
256
|
+
This library serves as the foundation for specialized tools and MCP servers:
|
|
270
257
|
|
|
271
258
|
```python
|
|
272
259
|
# Foundation library
|
|
273
260
|
import kicad_sch_api as ksa
|
|
274
261
|
|
|
275
|
-
#
|
|
276
|
-
#
|
|
277
|
-
#
|
|
278
|
-
#
|
|
262
|
+
# MCP servers and specialized libraries built on this foundation:
|
|
263
|
+
# - mcp-kicad-sch-api: Full MCP server for AI agents
|
|
264
|
+
# - kicad_sourcing_tools: Component sourcing extensions
|
|
265
|
+
# - kicad_placement_optimizer: Layout optimization
|
|
266
|
+
# - kicad_dfm_checker: Manufacturing validation
|
|
279
267
|
|
|
280
268
|
# Foundation provides reliable schematic manipulation
|
|
281
269
|
sch = ksa.load_schematic('project.kicad_sch')
|
|
282
270
|
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
271
|
+
# All extensions use the same stable API
|
|
272
|
+
# mcp_server.use_schematic(sch) # MCP server integration
|
|
273
|
+
# sourcing.update_sourcing(sch) # Component sourcing
|
|
274
|
+
# placement.optimize_layout(sch) # Layout optimization
|
|
287
275
|
|
|
288
|
-
#
|
|
276
|
+
# Foundation ensures exact format preservation
|
|
289
277
|
sch.save() # Guaranteed exact KiCAD format
|
|
290
278
|
```
|
|
291
279
|
|
|
@@ -313,6 +301,7 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
313
301
|
|
|
314
302
|
## 🔗 Related Projects
|
|
315
303
|
|
|
304
|
+
- **[mcp-kicad-sch-api](https://github.com/circuit-synth/mcp-kicad-sch-api)**: MCP server for AI agents built on this library
|
|
316
305
|
- **[circuit-synth](https://github.com/circuit-synth/circuit-synth)**: High-level circuit design automation using this library
|
|
317
306
|
- **[Claude Code](https://claude.ai/code)**: AI development environment with MCP support
|
|
318
307
|
- **[KiCAD](https://kicad.org/)**: Open source electronics design automation suite
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
kicad_sch_api/__init__.py,sha256=mogTeOic6O-WWOfpoRuBzPicVNha-gbdMrhJX4ir5PY,2821
|
|
2
|
-
kicad_sch_api/cli.py,sha256=
|
|
2
|
+
kicad_sch_api/cli.py,sha256=QWUwxEyo7xcDPRH_s7dsgSi2F4ozI_RA6yF9vtsn01Q,7934
|
|
3
3
|
kicad_sch_api/py.typed,sha256=e4ldqxwpY7pNDG1olbvj4HSKr8sZ9vxgA_2ek8xXn-Q,70
|
|
4
4
|
kicad_sch_api/core/__init__.py,sha256=ur_KeYBlGKl-e1hLpLdxAhGV2A-PCCGkcqd0r6KSeBA,566
|
|
5
5
|
kicad_sch_api/core/components.py,sha256=TiQrl7jdDTnuCWKdrlQC8-3b9PU58KoxTTnPX6VyZZk,24759
|
|
@@ -14,13 +14,11 @@ kicad_sch_api/discovery/__init__.py,sha256=0ky_FT58x-6aez6R9nhH2BBV27yG1N8EutRbR
|
|
|
14
14
|
kicad_sch_api/discovery/search_index.py,sha256=Yl3PXRk19mXCDtABM6Bs0ii0HMGiUAmIpD7xZjt7oEU,15943
|
|
15
15
|
kicad_sch_api/library/__init__.py,sha256=NG9UTdcpn25Bl9tPsYs9ED7bvpaVPVdtLMbnxkQkOnU,250
|
|
16
16
|
kicad_sch_api/library/cache.py,sha256=NPJT-apWH_JfVG1aXJ0gDnfGu8es_2tYiyZr-chcTxY,33511
|
|
17
|
-
kicad_sch_api/mcp/__init__.py,sha256=Jw4gKdn9H-2MVUYBTIAb6s5Tz2mYc9KoQPRsx-voD4s,159
|
|
18
|
-
kicad_sch_api/mcp/server.py,sha256=OB79fTR0lZubxC1jm0Avib37Zv_-nqZPl4XrrL_qO4c,54445
|
|
19
17
|
kicad_sch_api/utils/__init__.py,sha256=1V_yGgI7jro6MUc4Pviux_WIeJ1wmiYFID186SZwWLQ,277
|
|
20
18
|
kicad_sch_api/utils/validation.py,sha256=XlWGRZJb3cOPYpU9sLQQgC_NASwbi6W-LCN7PzUmaPY,15626
|
|
21
|
-
kicad_sch_api-0.
|
|
22
|
-
kicad_sch_api-0.
|
|
23
|
-
kicad_sch_api-0.
|
|
24
|
-
kicad_sch_api-0.
|
|
25
|
-
kicad_sch_api-0.
|
|
26
|
-
kicad_sch_api-0.
|
|
19
|
+
kicad_sch_api-0.2.0.dist-info/licenses/LICENSE,sha256=Em65Nvte1G9MHc0rHqtYuGkCPcshD588itTa358J6gs,1070
|
|
20
|
+
kicad_sch_api-0.2.0.dist-info/METADATA,sha256=fDrGYR59K47HavX3LMlQj5_S_LqUXFbj2qpuGu2foWU,10428
|
|
21
|
+
kicad_sch_api-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
kicad_sch_api-0.2.0.dist-info/entry_points.txt,sha256=VWKsFi2Jv7G_tmio3cNVhhIBfv_OZFaKa-T_ED84lc8,57
|
|
23
|
+
kicad_sch_api-0.2.0.dist-info/top_level.txt,sha256=n0ex4gOJ1b_fARowcGqRzyOGZcHRhc5LZa6_vVgGxcI,14
|
|
24
|
+
kicad_sch_api-0.2.0.dist-info/RECORD,,
|