Fix: store capabilities as JSON string for consistent schema
Browse files- extract_mcp_clients.py +11 -2
extract_mcp_clients.py
CHANGED
|
@@ -57,13 +57,22 @@ def normalize_capabilities(caps):
|
|
| 57 |
return caps
|
| 58 |
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
def create_dataset_from_clients(clients_list, features=None):
|
| 61 |
"""Create a Hugging Face Dataset from the clients list."""
|
| 62 |
if features is None:
|
| 63 |
features = Features({
|
| 64 |
'name': Value('string'),
|
| 65 |
'version': Value('string'),
|
| 66 |
-
'capabilities': Value('
|
| 67 |
'last_seen': Value('string'),
|
| 68 |
})
|
| 69 |
|
|
@@ -73,7 +82,7 @@ def create_dataset_from_clients(clients_list, features=None):
|
|
| 73 |
record = {
|
| 74 |
'name': client['name'],
|
| 75 |
'version': client['version'],
|
| 76 |
-
'capabilities': client['capabilities'],
|
| 77 |
'last_seen': client['last_seen'],
|
| 78 |
}
|
| 79 |
records.append(record)
|
|
|
|
| 57 |
return caps
|
| 58 |
|
| 59 |
|
| 60 |
+
def capabilities_to_string(caps):
|
| 61 |
+
"""Convert capabilities to JSON string for storage."""
|
| 62 |
+
if caps is None:
|
| 63 |
+
return ''
|
| 64 |
+
if isinstance(caps, dict):
|
| 65 |
+
return json.dumps(caps, sort_keys=True)
|
| 66 |
+
return str(caps)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
def create_dataset_from_clients(clients_list, features=None):
|
| 70 |
"""Create a Hugging Face Dataset from the clients list."""
|
| 71 |
if features is None:
|
| 72 |
features = Features({
|
| 73 |
'name': Value('string'),
|
| 74 |
'version': Value('string'),
|
| 75 |
+
'capabilities': Value('string'), # Store as JSON string for consistency
|
| 76 |
'last_seen': Value('string'),
|
| 77 |
})
|
| 78 |
|
|
|
|
| 82 |
record = {
|
| 83 |
'name': client['name'],
|
| 84 |
'version': client['version'],
|
| 85 |
+
'capabilities': capabilities_to_string(client['capabilities']),
|
| 86 |
'last_seen': client['last_seen'],
|
| 87 |
}
|
| 88 |
records.append(record)
|