import_fusesoc_core
Add local FuseSoC cores to your FPGA project registry by importing .core files with their HDL dependencies.
Instructions
Import a local FuseSoC CAPI2 .core file into the registry. HDL files referenced in the .core file must exist in the same directory. Useful when you already have FuseSoC cores checked out locally.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute or relative path to the .core file |
Implementation Reference
- registry/resolver.py:140-185 (handler)Main handler function that imports a FuseSoC CAPI2 .core file. It validates the file path, loads the core manifest using load_core_file helper, copies referenced HDL files to the registry directory with security checks, saves the manifest as core.json, and returns import status with metadata.
def import_fusesoc_core(self, path: str) -> dict: """Import a local CAPI2 .core file. HDL files must be in the same directory.""" from registry.fusesoc import load_core_file src = Path(path) if not src.exists(): return {"error": f"File not found: {path}"} manifest_dict = load_core_file(src) if not manifest_dict: return {"error": f"Could not parse CAPI2 .core file: {path}"} core_name = manifest_dict["name"] dest_dir = self._dir / core_name dest_dir.mkdir(parents=True, exist_ok=True) copied: list[str] = [] for fname in manifest_dict.get("files", []): rel = Path(fname) if rel.is_absolute() or rel.drive or ".." in rel.parts: return {"error": f"Unsafe file path in core file: {fname}"} src_hdl = (src.parent / rel).resolve() if not src_hdl.is_relative_to(src.parent.resolve()): return {"error": f"Unsafe source path in core file: {fname}"} if src_hdl.exists(): dest_file = (dest_dir / rel).resolve() if not dest_file.is_relative_to(dest_dir.resolve()): return {"error": f"Unsafe destination path in core file: {fname}"} dest_file.parent.mkdir(parents=True, exist_ok=True) dest_file.write_text( src_hdl.read_text(encoding="utf-8"), encoding="utf-8" ) copied.append(rel.as_posix()) manifest_dict["files"] = copied or manifest_dict.get("files", []) (dest_dir / "core.json").write_text( json.dumps(manifest_dict, indent=2), encoding="utf-8" ) self._load_all() return { "imported": True, "core_name": core_name, "files_copied": copied, "manifest": manifest_dict, } - server.py:235-250 (schema)Tool registration with name, description, and inputSchema defining the 'path' parameter as a required string for the .core file path.
types.Tool( name="import_fusesoc_core", description=( "Import a local FuseSoC CAPI2 .core file into the registry. " "HDL files referenced in the .core file must exist in the same directory. " "Useful when you already have FuseSoC cores checked out locally." ), inputSchema={ "type": "object", "properties": { "path": { "type": "string", "description": "Absolute or relative path to the .core file", }, }, "required": ["path"], - server.py:463-466 (registration)Dispatch logic in the tool call handler that invokes the import_fusesoc_core method asynchronously via asyncio.to_thread.
case "import_fusesoc_core": result = await asyncio.to_thread( registry.import_fusesoc_core, path=arguments["path"] ) - registry/fusesoc.py:130-138 (helper)Helper function that loads a CAPI2 .core file and converts it to a manifest dictionary using capi2_to_manifest_dict.
def load_core_file(path: Path) -> dict | None: """Load a local CAPI2 .core file and return a manifest dict.""" try: return capi2_to_manifest_dict( path.read_text(encoding="utf-8"), source=str(path), ) except Exception: return None