MCPcopy
hub / github.com/MinishLab/semble / serve

Function serve

src/semble/mcp.py:138–161  ·  view source on GitHub ↗

Start an MCP stdio server.

(
    content: Sequence[ContentType] = (ContentType.CODE,),
)

Source from the content-addressed store, hash-verified

136
137
138async def serve(
139 content: Sequence[ContentType] = (ContentType.CODE,),
140) -> None:
141 """Start an MCP stdio server."""
142 cache = _IndexCache(content=content)
143
144 async def _load_and_prewarm() -> None:
145 """Pre-load the embedding model in parallel with starting the server."""
146 try:
147 _, cache._model_path = await asyncio.to_thread(load_model)
148 except Exception as exc:
149 logger.exception("Failed to load embedding model")
150 cache._model_error = exc
151 return
152 finally:
153 cache._model_ready.set()
154
155 init_task = asyncio.create_task(_load_and_prewarm())
156 server = create_server(cache)
157 try:
158 await server.run_stdio_async()
159 finally:
160 if not init_task.done():
161 init_task.cancel()
162
163
164class _IndexCache:

Callers 3

_mcp_mainFunction · 0.90
test_serve_runs_stdioFunction · 0.90

Calls 3

_IndexCacheClass · 0.85
_load_and_prewarmFunction · 0.85
create_serverFunction · 0.85

Tested by 2

test_serve_runs_stdioFunction · 0.72