fiftyone-mcp-server 0.1.0__tar.gz
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.
- fiftyone_mcp_server-0.1.0/PKG-INFO +174 -0
- fiftyone_mcp_server-0.1.0/README.md +142 -0
- fiftyone_mcp_server-0.1.0/pyproject.toml +57 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/__init__.py +11 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/config/settings.json +15 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/server.py +127 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/tools/__init__.py +7 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/tools/datasets.py +210 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/tools/operators.py +575 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/tools/plugins.py +289 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/tools/session.py +352 -0
- fiftyone_mcp_server-0.1.0/src/fiftyone_mcp/tools/utils.py +112 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fiftyone-mcp-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server exposing FiftyOne dataset analysis tools
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: mcp,fiftyone,computer-vision,ai,datasets,model-context-protocol
|
|
7
|
+
Author: Adonai Vera
|
|
8
|
+
Author-email: adonai.vera@gmail.com
|
|
9
|
+
Requires-Python: >=3.10,<3.14
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
22
|
+
Requires-Dist: fiftyone (>=1.0,<2.0)
|
|
23
|
+
Requires-Dist: mcp (>=0.9.0,<0.10.0)
|
|
24
|
+
Requires-Dist: torch (>=2.9.1,<3.0.0)
|
|
25
|
+
Requires-Dist: torchvision (>=0.24.1,<0.25.0)
|
|
26
|
+
Requires-Dist: ultralytics (>=8.3.240,<9.0.0)
|
|
27
|
+
Project-URL: Documentation, https://github.com/AdonaiVera/fiftyone-mcp-server#readme
|
|
28
|
+
Project-URL: Homepage, https://github.com/AdonaiVera/fiftyone-mcp-server
|
|
29
|
+
Project-URL: Repository, https://github.com/AdonaiVera/fiftyone-mcp-server
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# FiftyOne MCP Server
|
|
33
|
+
|
|
34
|
+
<div align="center">
|
|
35
|
+
<p align="center">
|
|
36
|
+
|
|
37
|
+
<!-- prettier-ignore -->
|
|
38
|
+
<img src="https://user-images.githubusercontent.com/25985824/106288517-2422e000-6216-11eb-871d-26ad2e7b1e59.png" height="55px">
|
|
39
|
+
<img src="https://user-images.githubusercontent.com/25985824/106288518-24bb7680-6216-11eb-8f10-60052c519586.png" height="50px">
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
> Control FiftyOne datasets through AI assistants using the Model Context Protocol
|
|
44
|
+
|
|
45
|
+
</p>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
## Overview
|
|
49
|
+
|
|
50
|
+
Enable ChatGPT and Claude to explore datasets, execute operators, and build computer vision workflows through natural language. This server exposes FiftyOne's operator framework (80+ built-in operators) through 16 MCP tools.
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- **Dataset Management (3 tools)** - List, load, and summarize datasets
|
|
55
|
+
- **Operator System (5 tools)** - Execute any FiftyOne operator dynamically
|
|
56
|
+
- Context management (dataset/view/selection)
|
|
57
|
+
- Operator discovery and schema resolution
|
|
58
|
+
- Dynamic execution interface
|
|
59
|
+
- **Plugin Management (5 tools)** - Discover and install FiftyOne plugins
|
|
60
|
+
- List available plugins and their operators
|
|
61
|
+
- Install plugins from GitHub on demand
|
|
62
|
+
- Enable/disable plugins dynamically
|
|
63
|
+
- **Session Management (3 tools)** - Control FiftyOne App for delegated execution
|
|
64
|
+
- Launch/close FiftyOne App server
|
|
65
|
+
- Required for background operators (brain, evaluation, etc.)
|
|
66
|
+
- Session info and status monitoring
|
|
67
|
+
- **Natural Language Workflows** - Multi-step operations through conversation
|
|
68
|
+
- **ChatGPT & Claude Compatible** - Works with desktop apps
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/AdonaiVera/fiftyone-mcp-server.git
|
|
74
|
+
cd fiftyone-mcp-server
|
|
75
|
+
poetry install
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Requirements:** Python 3.10-3.13, Poetry, FiftyOne
|
|
79
|
+
|
|
80
|
+
## Configuration
|
|
81
|
+
|
|
82
|
+
Add to MCP config:
|
|
83
|
+
|
|
84
|
+
- ChatGPT: `~/Library/Application Support/ChatGPT/config.json`
|
|
85
|
+
- Claude: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"fiftyone": {
|
|
91
|
+
"command": "poetry",
|
|
92
|
+
"args": ["run", "fiftyone-mcp"],
|
|
93
|
+
"cwd": "/absolute/path/to/fiftyone-mcp-server"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Restart your AI assistant.
|
|
100
|
+
|
|
101
|
+
## Usage
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
# Run
|
|
105
|
+
poetry run fiftyone-mcp
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
And then you can query directly the agent:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
"List all my datasets"
|
|
112
|
+
"Load quickstart dataset and show summary"
|
|
113
|
+
"What operators are available for managing samples?"
|
|
114
|
+
"Set context to my dataset, then tag high-confidence samples"
|
|
115
|
+
"What plugins are available? Install the brain plugin"
|
|
116
|
+
"Find similar images in my dataset"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Example of functionality:
|
|
120
|
+
|
|
121
|
+
The server starts with 50 built-in operators. Install plugins to expand functionality - the AI can discover and install plugins automatically when needed (brain, zoo, annotation, evaluation, and more).
|
|
122
|
+
|
|
123
|
+
## Architecture
|
|
124
|
+
|
|
125
|
+
**Operator-Based Design:**
|
|
126
|
+
|
|
127
|
+
- Exposes 80+ FiftyOne operators through unified interface
|
|
128
|
+
- Dynamic schema resolution based on current context
|
|
129
|
+
- Context state management (dataset, view, selection)
|
|
130
|
+
|
|
131
|
+
**Plugin Architecture:**
|
|
132
|
+
|
|
133
|
+
- AI discovers plugins on demand through `list_plugins`
|
|
134
|
+
- Installs plugins automatically when needed
|
|
135
|
+
- All plugin operators immediately available after installation
|
|
136
|
+
- Self-expanding capability set
|
|
137
|
+
|
|
138
|
+
**Session Architecture:**
|
|
139
|
+
|
|
140
|
+
- AI can launch FiftyOne App when needed for delegated operators
|
|
141
|
+
- Enables background execution for compute-intensive operations
|
|
142
|
+
- Automatic session management through natural conversation
|
|
143
|
+
|
|
144
|
+
**Design Philosophy:**
|
|
145
|
+
|
|
146
|
+
- Minimal tool count (16 tools total)
|
|
147
|
+
- Maximum flexibility (access to full operator & plugin ecosystem)
|
|
148
|
+
- Mirrors FiftyOne App's execution model
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Run tests
|
|
154
|
+
poetry run pytest
|
|
155
|
+
|
|
156
|
+
# Code quality
|
|
157
|
+
poetry run black -l 79 src/
|
|
158
|
+
poetry run pylint --errors-only src/
|
|
159
|
+
|
|
160
|
+
# Test with MCP Inspector
|
|
161
|
+
npx @modelcontextprotocol/inspector poetry run fiftyone-mcp
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Resources
|
|
165
|
+
|
|
166
|
+
- [FiftyOne Docs](https://docs.voxel51.com/)
|
|
167
|
+
- [FiftyOne Operators](https://docs.voxel51.com/plugins/developing_plugins.html)
|
|
168
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
|
169
|
+
- [MCP Inspector](https://github.com/modelcontextprotocol/inspector)
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
Built with [FiftyOne](https://voxel51.com/fiftyone) and [Model Context Protocol](https://modelcontextprotocol.io)
|
|
174
|
+
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# FiftyOne MCP Server
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<p align="center">
|
|
5
|
+
|
|
6
|
+
<!-- prettier-ignore -->
|
|
7
|
+
<img src="https://user-images.githubusercontent.com/25985824/106288517-2422e000-6216-11eb-871d-26ad2e7b1e59.png" height="55px">
|
|
8
|
+
<img src="https://user-images.githubusercontent.com/25985824/106288518-24bb7680-6216-11eb-8f10-60052c519586.png" height="50px">
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
> Control FiftyOne datasets through AI assistants using the Model Context Protocol
|
|
13
|
+
|
|
14
|
+
</p>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
Enable ChatGPT and Claude to explore datasets, execute operators, and build computer vision workflows through natural language. This server exposes FiftyOne's operator framework (80+ built-in operators) through 16 MCP tools.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Dataset Management (3 tools)** - List, load, and summarize datasets
|
|
24
|
+
- **Operator System (5 tools)** - Execute any FiftyOne operator dynamically
|
|
25
|
+
- Context management (dataset/view/selection)
|
|
26
|
+
- Operator discovery and schema resolution
|
|
27
|
+
- Dynamic execution interface
|
|
28
|
+
- **Plugin Management (5 tools)** - Discover and install FiftyOne plugins
|
|
29
|
+
- List available plugins and their operators
|
|
30
|
+
- Install plugins from GitHub on demand
|
|
31
|
+
- Enable/disable plugins dynamically
|
|
32
|
+
- **Session Management (3 tools)** - Control FiftyOne App for delegated execution
|
|
33
|
+
- Launch/close FiftyOne App server
|
|
34
|
+
- Required for background operators (brain, evaluation, etc.)
|
|
35
|
+
- Session info and status monitoring
|
|
36
|
+
- **Natural Language Workflows** - Multi-step operations through conversation
|
|
37
|
+
- **ChatGPT & Claude Compatible** - Works with desktop apps
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/AdonaiVera/fiftyone-mcp-server.git
|
|
43
|
+
cd fiftyone-mcp-server
|
|
44
|
+
poetry install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Requirements:** Python 3.10-3.13, Poetry, FiftyOne
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
Add to MCP config:
|
|
52
|
+
|
|
53
|
+
- ChatGPT: `~/Library/Application Support/ChatGPT/config.json`
|
|
54
|
+
- Claude: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"fiftyone": {
|
|
60
|
+
"command": "poetry",
|
|
61
|
+
"args": ["run", "fiftyone-mcp"],
|
|
62
|
+
"cwd": "/absolute/path/to/fiftyone-mcp-server"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Restart your AI assistant.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
# Run
|
|
74
|
+
poetry run fiftyone-mcp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
And then you can query directly the agent:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
"List all my datasets"
|
|
81
|
+
"Load quickstart dataset and show summary"
|
|
82
|
+
"What operators are available for managing samples?"
|
|
83
|
+
"Set context to my dataset, then tag high-confidence samples"
|
|
84
|
+
"What plugins are available? Install the brain plugin"
|
|
85
|
+
"Find similar images in my dataset"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Example of functionality:
|
|
89
|
+
|
|
90
|
+
The server starts with 50 built-in operators. Install plugins to expand functionality - the AI can discover and install plugins automatically when needed (brain, zoo, annotation, evaluation, and more).
|
|
91
|
+
|
|
92
|
+
## Architecture
|
|
93
|
+
|
|
94
|
+
**Operator-Based Design:**
|
|
95
|
+
|
|
96
|
+
- Exposes 80+ FiftyOne operators through unified interface
|
|
97
|
+
- Dynamic schema resolution based on current context
|
|
98
|
+
- Context state management (dataset, view, selection)
|
|
99
|
+
|
|
100
|
+
**Plugin Architecture:**
|
|
101
|
+
|
|
102
|
+
- AI discovers plugins on demand through `list_plugins`
|
|
103
|
+
- Installs plugins automatically when needed
|
|
104
|
+
- All plugin operators immediately available after installation
|
|
105
|
+
- Self-expanding capability set
|
|
106
|
+
|
|
107
|
+
**Session Architecture:**
|
|
108
|
+
|
|
109
|
+
- AI can launch FiftyOne App when needed for delegated operators
|
|
110
|
+
- Enables background execution for compute-intensive operations
|
|
111
|
+
- Automatic session management through natural conversation
|
|
112
|
+
|
|
113
|
+
**Design Philosophy:**
|
|
114
|
+
|
|
115
|
+
- Minimal tool count (16 tools total)
|
|
116
|
+
- Maximum flexibility (access to full operator & plugin ecosystem)
|
|
117
|
+
- Mirrors FiftyOne App's execution model
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Run tests
|
|
123
|
+
poetry run pytest
|
|
124
|
+
|
|
125
|
+
# Code quality
|
|
126
|
+
poetry run black -l 79 src/
|
|
127
|
+
poetry run pylint --errors-only src/
|
|
128
|
+
|
|
129
|
+
# Test with MCP Inspector
|
|
130
|
+
npx @modelcontextprotocol/inspector poetry run fiftyone-mcp
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Resources
|
|
134
|
+
|
|
135
|
+
- [FiftyOne Docs](https://docs.voxel51.com/)
|
|
136
|
+
- [FiftyOne Operators](https://docs.voxel51.com/plugins/developing_plugins.html)
|
|
137
|
+
- [Model Context Protocol](https://modelcontextprotocol.io)
|
|
138
|
+
- [MCP Inspector](https://github.com/modelcontextprotocol/inspector)
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
Built with [FiftyOne](https://voxel51.com/fiftyone) and [Model Context Protocol](https://modelcontextprotocol.io)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "fiftyone-mcp-server"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server exposing FiftyOne dataset analysis tools"
|
|
5
|
+
authors = ["Adonai Vera <adonai.vera@gmail.com>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
homepage = "https://github.com/AdonaiVera/fiftyone-mcp-server"
|
|
9
|
+
repository = "https://github.com/AdonaiVera/fiftyone-mcp-server"
|
|
10
|
+
documentation = "https://github.com/AdonaiVera/fiftyone-mcp-server#readme"
|
|
11
|
+
keywords = ["mcp", "fiftyone", "computer-vision", "ai", "datasets", "model-context-protocol"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Intended Audience :: Science/Research",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Image Recognition",
|
|
25
|
+
]
|
|
26
|
+
packages = [{include = "fiftyone_mcp", from = "src"}]
|
|
27
|
+
|
|
28
|
+
[tool.poetry.dependencies]
|
|
29
|
+
python = ">=3.10,<3.14"
|
|
30
|
+
fiftyone = "^1.0"
|
|
31
|
+
mcp = "^0.9.0"
|
|
32
|
+
torch = "^2.9.1"
|
|
33
|
+
torchvision = "^0.24.1"
|
|
34
|
+
ultralytics = "^8.3.240"
|
|
35
|
+
|
|
36
|
+
[tool.poetry.group.dev.dependencies]
|
|
37
|
+
pytest = "^8.0.0"
|
|
38
|
+
pytest-asyncio = "^0.23.0"
|
|
39
|
+
black = "^24.0.0"
|
|
40
|
+
pylint = "^3.0.0"
|
|
41
|
+
pre-commit = "^3.5.0"
|
|
42
|
+
|
|
43
|
+
[tool.poetry.scripts]
|
|
44
|
+
fiftyone-mcp = "fiftyone_mcp.server:run"
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["poetry-core"]
|
|
48
|
+
build-backend = "poetry.core.masonry.api"
|
|
49
|
+
|
|
50
|
+
[tool.pytest.ini_options]
|
|
51
|
+
testpaths = ["tests"]
|
|
52
|
+
python_files = ["test_*.py"]
|
|
53
|
+
python_functions = ["test_*"]
|
|
54
|
+
|
|
55
|
+
[tool.black]
|
|
56
|
+
line-length = 79
|
|
57
|
+
target-version = ['py310']
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"server": {
|
|
3
|
+
"name": "fiftyone-mcp",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"default_port": 5149
|
|
6
|
+
},
|
|
7
|
+
"fiftyone": {
|
|
8
|
+
"database_dir": null,
|
|
9
|
+
"default_dataset": null
|
|
10
|
+
},
|
|
11
|
+
"logging": {
|
|
12
|
+
"level": "INFO",
|
|
13
|
+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FiftyOne MCP Server.
|
|
3
|
+
|
|
4
|
+
Main entrypoint for the FiftyOne Model Context Protocol server.
|
|
5
|
+
|
|
6
|
+
| Copyright 2017-2025, Voxel51, Inc.
|
|
7
|
+
| `voxel51.com <https://voxel51.com/>`_
|
|
8
|
+
|
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import asyncio
|
|
12
|
+
import json
|
|
13
|
+
import logging
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
from mcp.server import Server
|
|
17
|
+
from mcp.server.stdio import stdio_server
|
|
18
|
+
from mcp.types import TextContent
|
|
19
|
+
|
|
20
|
+
from .tools.datasets import get_dataset_tools
|
|
21
|
+
from .tools.operators import get_operator_tools
|
|
22
|
+
from .tools.plugins import get_plugin_tools
|
|
23
|
+
from .tools.session import get_session_tools
|
|
24
|
+
from .tools import datasets, operators, plugins, session
|
|
25
|
+
from .tools.utils import format_response
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
logging.basicConfig(
|
|
29
|
+
level=logging.INFO,
|
|
30
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
31
|
+
)
|
|
32
|
+
logger = logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load_config():
|
|
36
|
+
"""Loads configuration from settings.json.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
a config dict
|
|
40
|
+
"""
|
|
41
|
+
config_path = Path(__file__).parent / "config" / "settings.json"
|
|
42
|
+
try:
|
|
43
|
+
with open(config_path, "r") as f:
|
|
44
|
+
return json.load(f)
|
|
45
|
+
except Exception as e:
|
|
46
|
+
logger.warning(f"Could not load config from {config_path}: {e}")
|
|
47
|
+
return {}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
async def main():
|
|
51
|
+
"""Main server function."""
|
|
52
|
+
config = load_config()
|
|
53
|
+
server_config = config.get("server", {})
|
|
54
|
+
server_name = server_config.get("name", "fiftyone-mcp")
|
|
55
|
+
|
|
56
|
+
logger.info(f"Starting {server_name} server...")
|
|
57
|
+
|
|
58
|
+
server = Server(server_name)
|
|
59
|
+
|
|
60
|
+
all_tools = (
|
|
61
|
+
get_dataset_tools()
|
|
62
|
+
+ get_operator_tools()
|
|
63
|
+
+ get_plugin_tools()
|
|
64
|
+
+ get_session_tools()
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@server.list_tools()
|
|
68
|
+
async def list_tools_handler():
|
|
69
|
+
return all_tools
|
|
70
|
+
|
|
71
|
+
@server.call_tool()
|
|
72
|
+
async def call_tool_handler(name, arguments):
|
|
73
|
+
if name in ["list_datasets", "load_dataset", "dataset_summary"]:
|
|
74
|
+
return await datasets.handle_tool_call(name, arguments)
|
|
75
|
+
elif name in [
|
|
76
|
+
"set_context",
|
|
77
|
+
"get_context",
|
|
78
|
+
"list_operators",
|
|
79
|
+
"get_operator_schema",
|
|
80
|
+
"execute_operator",
|
|
81
|
+
]:
|
|
82
|
+
return await operators.handle_tool_call(name, arguments)
|
|
83
|
+
elif name in [
|
|
84
|
+
"list_plugins",
|
|
85
|
+
"get_plugin_info",
|
|
86
|
+
"download_plugin",
|
|
87
|
+
"enable_plugin",
|
|
88
|
+
"disable_plugin",
|
|
89
|
+
]:
|
|
90
|
+
return await plugins.handle_plugin_tool(name, arguments)
|
|
91
|
+
elif name in [
|
|
92
|
+
"launch_app",
|
|
93
|
+
"close_app",
|
|
94
|
+
"get_session_info",
|
|
95
|
+
"set_view",
|
|
96
|
+
"clear_view",
|
|
97
|
+
]:
|
|
98
|
+
return await session.handle_session_tool(name, arguments)
|
|
99
|
+
else:
|
|
100
|
+
result = format_response(
|
|
101
|
+
None, success=False, error=f"Unknown tool: {name}"
|
|
102
|
+
)
|
|
103
|
+
return [
|
|
104
|
+
TextContent(type="text", text=json.dumps(result, indent=2))
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
logger.info(f"{server_name} server initialized successfully")
|
|
108
|
+
|
|
109
|
+
async with stdio_server() as (read_stream, write_stream):
|
|
110
|
+
await server.run(
|
|
111
|
+
read_stream, write_stream, server.create_initialization_options()
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def run():
|
|
116
|
+
"""Entry point for the server."""
|
|
117
|
+
try:
|
|
118
|
+
asyncio.run(main())
|
|
119
|
+
except KeyboardInterrupt:
|
|
120
|
+
logger.info("Server stopped by user")
|
|
121
|
+
except Exception as e:
|
|
122
|
+
logger.error(f"Server error: {e}", exc_info=True)
|
|
123
|
+
raise
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if __name__ == "__main__":
|
|
127
|
+
run()
|