Coverage for app / mcp / registry.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-10-31 11:23 +0000

1""" 

2Built-in MCP (Model Context Protocol) server template registry for svc-ai. 

3 

4Each entry defines a popular/supported MCP server that users can configure 

5and connect to their agents. Templates specify connection schema, default 

6config, and a preview of the tools the server exposes. 

7""" 

8 

9from __future__ import annotations 

10 

11from dataclasses import dataclass, field 

12from typing import Any, Literal 

13 

14from app.util.registry import BuiltinRegistry 

15 

16MCPConnectionType = Literal["stdio", "http", "sse"] 

17 

18 

19@dataclass 

20class MCPConfigField: 

21 key: str 

22 label: str 

23 type: Literal["string", "password", "array", "object"] 

24 description: str 

25 required: bool = True 

26 default: Any = None 

27 placeholder: str = "" 

28 

29 

30@dataclass 

31class MCPServerTemplate: 

32 key: str # unique identifier 

33 name: str # display name 

34 description: str 

35 connection_type: MCPConnectionType 

36 icon_hint: str # keyword for frontend icon resolution 

37 category: str # grouping: "filesystem", "search", "data", "communication", "dev" 

38 config_fields: list[MCPConfigField] = field(default_factory=list) 

39 tools_preview: list[str] = field( 

40 default_factory=list 

41 ) # approximate list of exposed tool names 

42 docs_url: str = "" 

43 

44 

45_BUILTIN_MCP_SERVERS: dict[str, MCPServerTemplate] = { 

46 "filesystem": MCPServerTemplate( 

47 key="filesystem", 

48 name="Filesystem", 

49 description="Read and write files on the local filesystem. Agents can list directories, read file contents, write and edit files, and search within paths.", 

50 connection_type="stdio", 

51 icon_hint="file", 

52 category="filesystem", 

53 config_fields=[ 

54 MCPConfigField( 

55 key="command", 

56 label="Command", 

57 type="string", 

58 description="Path to the MCP filesystem server binary or npx invocation.", 

59 placeholder="npx @modelcontextprotocol/server-filesystem", 

60 default="npx @modelcontextprotocol/server-filesystem", 

61 ), 

62 MCPConfigField( 

63 key="args", 

64 label="Allowed Paths", 

65 type="array", 

66 description="List of filesystem paths the server is permitted to access.", 

67 placeholder="/home/user/data", 

68 required=False, 

69 default=[], 

70 ), 

71 ], 

72 tools_preview=[ 

73 "read_file", 

74 "read_multiple_files", 

75 "write_file", 

76 "edit_file", 

77 "create_directory", 

78 "list_directory", 

79 "move_file", 

80 "search_files", 

81 "get_file_info", 

82 ], 

83 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem", 

84 ), 

85 "brave_search": MCPServerTemplate( 

86 key="brave_search", 

87 name="Brave Search", 

88 description="Web, news, image, video and local search powered by the Brave Search API. Provides real-time results from Brave's independent index.", 

89 connection_type="stdio", 

90 icon_hint="search", 

91 category="search", 

92 config_fields=[ 

93 MCPConfigField( 

94 key="api_key", 

95 label="Brave Search API Key", 

96 type="password", 

97 description="Your Brave Search API key from https://brave.com/search/api/", 

98 placeholder="BSA...", 

99 ), 

100 MCPConfigField( 

101 key="command", 

102 label="Command", 

103 type="string", 

104 description="Path to the Brave Search MCP server binary.", 

105 placeholder="npx @brave/brave-search-mcp-server", 

106 default="npx @brave/brave-search-mcp-server", 

107 ), 

108 ], 

109 tools_preview=[ 

110 "brave_web_search", 

111 "brave_news_search", 

112 "brave_image_search", 

113 "brave_video_search", 

114 "brave_local_search", 

115 ], 

116 docs_url="https://github.com/brave/brave-search-mcp-server", 

117 ), 

118 "github": MCPServerTemplate( 

119 key="github", 

120 name="GitHub", 

121 description="Interact with GitHub repositories, issues, pull requests, and code search via the GitHub API.", 

122 connection_type="stdio", 

123 icon_hint="code", 

124 category="dev", 

125 config_fields=[ 

126 MCPConfigField( 

127 key="token", 

128 label="GitHub Personal Access Token", 

129 type="password", 

130 description="A GitHub PAT with the scopes required for your use case (repo, issues, pull_requests, etc.).", 

131 placeholder="ghp_...", 

132 ), 

133 MCPConfigField( 

134 key="command", 

135 label="Command", 

136 type="string", 

137 description="Path to the GitHub MCP server binary.", 

138 placeholder="npx @modelcontextprotocol/server-github", 

139 default="npx @modelcontextprotocol/server-github", 

140 ), 

141 ], 

142 tools_preview=[ 

143 "get_file_contents", 

144 "search_repositories", 

145 "create_issue", 

146 "create_pull_request", 

147 "list_issues", 

148 "list_pull_requests", 

149 "get_issue", 

150 "search_code", 

151 ], 

152 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/github", 

153 ), 

154 "gitlab": MCPServerTemplate( 

155 key="gitlab", 

156 name="GitLab", 

157 description="Interact with GitLab projects, merge requests, issues, and CI/CD pipelines.", 

158 connection_type="stdio", 

159 icon_hint="code", 

160 category="dev", 

161 config_fields=[ 

162 MCPConfigField( 

163 key="token", 

164 label="GitLab Personal Access Token", 

165 type="password", 

166 description="A GitLab PAT with api scope.", 

167 placeholder="glpat-...", 

168 ), 

169 MCPConfigField( 

170 key="url", 

171 label="GitLab URL", 

172 type="string", 

173 description="Your GitLab instance URL (leave as default for gitlab.com).", 

174 placeholder="https://gitlab.com", 

175 default="https://gitlab.com", 

176 required=False, 

177 ), 

178 MCPConfigField( 

179 key="command", 

180 label="Command", 

181 type="string", 

182 description="Path to the GitLab MCP server binary.", 

183 placeholder="npx @modelcontextprotocol/server-gitlab", 

184 default="npx @modelcontextprotocol/server-gitlab", 

185 ), 

186 ], 

187 tools_preview=[ 

188 "get_file_contents", 

189 "list_projects", 

190 "create_issue", 

191 "create_merge_request", 

192 "list_merge_requests", 

193 ], 

194 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/gitlab", 

195 ), 

196 "memory": MCPServerTemplate( 

197 key="memory", 

198 name="Memory", 

199 description="Persistent key-value memory store for agents. Allows agents to remember and retrieve information across sessions.", 

200 connection_type="stdio", 

201 icon_hint="database", 

202 category="data", 

203 config_fields=[ 

204 MCPConfigField( 

205 key="command", 

206 label="Command", 

207 type="string", 

208 description="Path to the memory MCP server binary.", 

209 placeholder="npx @modelcontextprotocol/server-memory", 

210 default="npx @modelcontextprotocol/server-memory", 

211 ), 

212 ], 

213 tools_preview=[ 

214 "create_entities", 

215 "create_relations", 

216 "add_observations", 

217 "delete_entities", 

218 "delete_observations", 

219 "delete_relations", 

220 "read_graph", 

221 "search_nodes", 

222 "open_nodes", 

223 ], 

224 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/memory", 

225 ), 

226 "fetch": MCPServerTemplate( 

227 key="fetch", 

228 name="Fetch", 

229 description="Fetch content from arbitrary URLs. Useful for reading web pages, APIs, or any HTTP resource.", 

230 connection_type="stdio", 

231 icon_hint="web", 

232 category="search", 

233 config_fields=[ 

234 MCPConfigField( 

235 key="command", 

236 label="Command", 

237 type="string", 

238 description="Path to the fetch MCP server binary.", 

239 placeholder="uvx mcp-server-fetch", 

240 default="uvx mcp-server-fetch", 

241 ), 

242 MCPConfigField( 

243 key="allowed_domains", 

244 label="Allowed Domains", 

245 type="array", 

246 description="Restrict fetches to these domains. Leave empty to allow all.", 

247 required=False, 

248 default=[], 

249 ), 

250 ], 

251 tools_preview=["fetch"], 

252 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/fetch", 

253 ), 

254 "postgres": MCPServerTemplate( 

255 key="postgres", 

256 name="PostgreSQL", 

257 description="Execute read-only SQL queries against a PostgreSQL database. Agents can inspect schema and run SELECT queries.", 

258 connection_type="stdio", 

259 icon_hint="database", 

260 category="data", 

261 config_fields=[ 

262 MCPConfigField( 

263 key="connection_string", 

264 label="Connection String", 

265 type="password", 

266 description="PostgreSQL connection URI (e.g. postgresql://user:pass@host:5432/dbname).", 

267 placeholder="postgresql://user:password@localhost:5432/mydb", 

268 ), 

269 MCPConfigField( 

270 key="command", 

271 label="Command", 

272 type="string", 

273 description="Path to the PostgreSQL MCP server binary.", 

274 placeholder="npx @modelcontextprotocol/server-postgres", 

275 default="npx @modelcontextprotocol/server-postgres", 

276 ), 

277 ], 

278 tools_preview=["query"], 

279 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/postgres", 

280 ), 

281 "slack": MCPServerTemplate( 

282 key="slack", 

283 name="Slack", 

284 description="Read channels, post messages, and interact with Slack workspaces via the Slack API.", 

285 connection_type="stdio", 

286 icon_hint="email", 

287 category="communication", 

288 config_fields=[ 

289 MCPConfigField( 

290 key="bot_token", 

291 label="Slack Bot Token", 

292 type="password", 

293 description="Slack Bot User OAuth Token (xoxb-...).", 

294 placeholder="xoxb-...", 

295 ), 

296 MCPConfigField( 

297 key="team_id", 

298 label="Team ID", 

299 type="string", 

300 description="Your Slack workspace Team ID.", 

301 placeholder="T0123456789", 

302 required=False, 

303 ), 

304 MCPConfigField( 

305 key="command", 

306 label="Command", 

307 type="string", 

308 description="Path to the Slack MCP server binary.", 

309 placeholder="npx @modelcontextprotocol/server-slack", 

310 default="npx @modelcontextprotocol/server-slack", 

311 ), 

312 ], 

313 tools_preview=[ 

314 "slack_list_channels", 

315 "slack_post_message", 

316 "slack_reply_to_thread", 

317 "slack_get_channel_history", 

318 "slack_search_messages", 

319 ], 

320 docs_url="https://github.com/modelcontextprotocol/servers/tree/main/src/slack", 

321 ), 

322 "custom_http": MCPServerTemplate( 

323 key="custom_http", 

324 name="Custom HTTP/SSE Server", 

325 description="Connect to any custom MCP server exposed over HTTP or Server-Sent Events (SSE).", 

326 connection_type="http", 

327 icon_hint="web", 

328 category="custom", 

329 config_fields=[ 

330 MCPConfigField( 

331 key="url", 

332 label="Server URL", 

333 type="string", 

334 description="Base URL of the MCP server (e.g. https://my-mcp-server.example.com).", 

335 placeholder="https://my-mcp-server.example.com", 

336 ), 

337 MCPConfigField( 

338 key="headers", 

339 label="Headers", 

340 type="object", 

341 description="Optional HTTP headers to include with every request (e.g. Authorization).", 

342 required=False, 

343 default={}, 

344 ), 

345 ], 

346 tools_preview=[], 

347 docs_url="https://modelcontextprotocol.io/docs/concepts/transports", 

348 ), 

349 "custom_stdio": MCPServerTemplate( 

350 key="custom_stdio", 

351 name="Custom stdio Server", 

352 description="Launch any custom MCP server as a local subprocess communicating over stdin/stdout.", 

353 connection_type="stdio", 

354 icon_hint="terminal", 

355 category="custom", 

356 config_fields=[ 

357 MCPConfigField( 

358 key="command", 

359 label="Command", 

360 type="string", 

361 description="Executable command to launch the MCP server.", 

362 placeholder="/usr/local/bin/my-mcp-server", 

363 ), 

364 MCPConfigField( 

365 key="args", 

366 label="Arguments", 

367 type="array", 

368 description="Command-line arguments to pass to the server process.", 

369 required=False, 

370 default=[], 

371 ), 

372 MCPConfigField( 

373 key="env", 

374 label="Environment Variables", 

375 type="object", 

376 description="Environment variables to set for the server process.", 

377 required=False, 

378 default={}, 

379 ), 

380 ], 

381 tools_preview=[], 

382 docs_url="https://modelcontextprotocol.io/docs/concepts/transports", 

383 ), 

384} 

385 

386BUILTIN_MCP_SERVERS: BuiltinRegistry[MCPServerTemplate] = BuiltinRegistry( 

387 _BUILTIN_MCP_SERVERS.values(), key=lambda t: t.key 

388)