MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / build_server

Function build_server

src/ifcmcp/ifcmcp/server.py:17–231  ·  view source on GitHub ↗

Create the FastMCP server if the dependency is available.

()

Source from the content-addressed store, hash-verified

15
16
17def build_server() -> Any:
18 """Create the FastMCP server if the dependency is available."""
19 if FastMCP is None:
20 raise ImportError(
21 "FastMCP is not installed. Install with: pip install ifcmcp[mcp] " "(or add 'mcp' to your environment)."
22 )
23
24 session = IfcSession()
25
26 server = FastMCP(
27 name="ifc-mcp",
28 instructions=(
29 "MCP server for querying and editing IFC building models. "
30 "Load a file first with ifc_load, then use query/edit tools. "
31 "Save changes with ifc_save."
32 ),
33 )
34
35 # ---- Lifecycle ----
36 @server.tool()
37 def ifc_new(schema: str = "IFC4") -> dict[str, Any]:
38 return session.ifc_new(schema=schema)
39
40 @server.tool()
41 def ifc_load(path: str) -> str:
42 return session.ifc_load(path)
43
44 @server.tool()
45 def ifc_save(path: str = "") -> str:
46 return session.ifc_save(path)
47
48 @server.tool()
49 def ifc_reset() -> dict[str, Any]:
50 return session.ifc_reset()
51
52 # ---- Query ----
53 @server.tool()
54 def ifc_summary() -> dict[str, Any]:
55 return session.ifc_summary()
56
57 @server.tool()
58 def ifc_tree() -> dict[str, Any] | list[dict[str, Any]]:
59 return session.ifc_tree()
60
61 @server.tool()
62 def ifc_info(element_id: int) -> dict[str, Any]:
63 return session.ifc_info(element_id)
64
65 @server.tool()
66 def ifc_select(query: str) -> list[dict[str, Any]]:
67 return session.ifc_select(query)
68
69 @server.tool()
70 def ifc_relations(element_id: int, traverse: str = "") -> dict[str, Any] | list[dict[str, Any]]:
71 return session.ifc_relations(element_id, traverse=traverse)
72
73 @server.tool()
74 def ifc_clash(

Callers 4

mainFunction · 0.90
test_server_nameMethod · 0.90
tool_fnsFunction · 0.90

Calls 1

IfcSessionClass · 0.90

Tested by 3

test_server_nameMethod · 0.72
tool_fnsFunction · 0.72