1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
|
"""Skill and MCP marketplace for Agentux.
Provides a browsable, installable catalogue of community-contributed
skills and MCP servers. Data lives in JSON files under
``~/.config/agentux/marketplace/`` so the catalogue works offline
and can be synced via git or any file-sharing method.
Each entry is a small JSON object:
{
"name": "skill-name", # slug, must be unique in its kind
"kind": "skill" | "mcp",
"title": "Human-readable title",
"description": "One-paragraph summary",
"author": "GitHub handle or name",
"source": "https://github.com/user/repo", # for skills: the repo; for MCPs: the repo with the server code
"entry": { # how to activate it in Agentux
"skill": { # for kind == "skill"
"module": "package.submodule:function", # dotted path to the skill function
"args": "optional default args string"
},
"mcp": { # for kind == "mcp"
"config": { # minimal MCP server config to merge
"command": "npx",
"args": ["-y", "package"]
}
}
},
"tags": ["utility", "formatting"], # free-form tags for search
"version": "1.0.0", # semver, informational
"license": "MIT" # SPDX identifier
}
The catalogue itself is a JSON array under ``catalogue.json``.
A local ``installed.json`` tracks what the user has added to their
``.agentux/skills.py`` or ``.agentux/mcp.json`` files.
"""
from __future__ import annotations
import json
import os
import time
from dataclasses import dataclass, asdict, field
from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional
MARKETPLACE_DIR = Path(os.path.expanduser("~/.config/agentux/marketplace"))
CATALOGUE_PATH = MARKETPLACE_DIR / "catalogue.json"
INSTALLED_PATH = MARKETPLACE_DIR / "installed.json"
class MarketplaceItemType(Enum):
"""Type of marketplace item."""
SKILL = "skill"
MCP_SERVER = "mcp"
@dataclass
class MarketplaceEntry:
"""A single skill or MCP server entry in the marketplace.
This class is maintained for backwards compatibility.
New code should use MarketplaceItem instead.
"""
id: str
name: str
kind: str # "skill" or "mcp"
title: str
description: str
author: str
source: str
entry: Dict[str, Any]
tags: List[str] = field(default_factory=list)
version: str = "1.0.0"
license: str = "MIT"
homepage: Optional[str] = None
installed: bool = False
enabled: bool = False
created_at: float = field(default_factory=time.time)
updated_at: float = field(default_factory=time.time)
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary for serialization."""
return asdict(self)
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "MarketplaceEntry":
"""Create from dictionary."""
return cls(**data)
@dataclass
class MarketplaceItem:
"""A single skill or MCP server entry in the marketplace."""
id: str
name: str
type: MarketplaceItemType
title: str
description: str
author: str
source: str
entry: Dict[str, Any]
tags: List[str] = field(default_factory=list)
version: str = "1.0.0"
license: str = "MIT"
homepage: Optional[str] = None
installed: bool = False
enabled: bool = False
created_at: float = field(default_factory=time.time)
updated_at: float = field(default_factory=time.time)
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary for serialization."""
data = asdict(self)
# Convert enum to string
data['type'] = self.type.value
# Also add kind field for backwards compatibility
data['kind'] = self.type.value
return data
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "MarketplaceItem":
"""Create from dictionary."""
# Convert type string back to enum
if 'type' in data and isinstance(data['type'], str):
data['type'] = MarketplaceItemType(data['type'])
# Also convert kind field if present (for backwards compatibility)
if 'kind' in data and isinstance(data['kind'], str) and 'type' not in data:
data['type'] = MarketplaceItemType(data['kind'])
# `kind` is a legacy alias for `type`; drop it so it is not passed
# to __init__ as a duplicate keyword argument.
data.pop('kind', None)
return cls(**data)
def _ensure_dir() -> None:
"""Create the marketplace directory if it does not exist."""
MARKETPLACE_DIR.mkdir(parents=True, exist_ok=True)
def _load_catalogue_items() -> List[MarketplaceItem]:
"""Load the marketplace catalogue from disk.
Returns an empty list if the file is missing or unreadable.
"""
_ensure_dir()
if not CATALOGUE_PATH.exists():
return []
try:
with CATALOGUE_PATH.open("r", encoding="utf-8") as f:
raw = json.load(f)
if not isinstance(raw, list):
return []
return [MarketplaceItem.from_dict(item) for item in raw]
except (json.JSONDecodeError, OSError):
return []
def _save_catalogue_to_disk(items: List[MarketplaceItem]) -> None:
"""Overwrite the catalogue file with the given items.
Disk-only. The public :func:`save_catalogue` below delegates to a
Marketplace instance, so this name is private to avoid the recursion.
"""
_ensure_dir()
with CATALOGUE_PATH.open("w", encoding="utf-8") as f:
json.dump([item.to_dict() for item in items], f, indent=2, ensure_ascii=False)
def _load_installed_from_disk() -> List[str]:
"""Return the list of entry names the user has installed."""
_ensure_dir()
if not INSTALLED_PATH.exists():
return []
try:
with INSTALLED_PATH.open("r", encoding="utf-8") as f:
data = json.load(f)
if not isinstance(data, list):
return []
return [str(name) for name in data]
except (json.JSONDecodeError, OSError):
return []
def _save_installed_to_disk(names: List[str]) -> None:
"""Overwrite the installed list with the given names."""
_ensure_dir()
with INSTALLED_PATH.open("w", encoding="utf-8") as f:
json.dump(sorted(set(names)), f, indent=2, ensure_ascii=False)
def install_entry(name: str) -> bool:
"""Mark an entry as installed; returns True if the name was not already present."""
installed = _load_installed_from_disk()
if name in installed:
return False
installed.append(name)
_save_installed_to_disk(installed)
return True
def uninstall_entry(name: str) -> bool:
"""Mark an entry as uninstalled; returns True if the name was present."""
installed = _load_installed_from_disk()
if name not in installed:
return False
installed.remove(name)
_save_installed_to_disk(installed)
return True
def is_installed(name: str) -> bool:
"""Check whether an entry is marked as installed."""
return name in _load_installed_from_disk()
def search_catalogue(query: str = "", kind: Optional[str] = None) -> List[MarketplaceItem]:
"""Return catalogue entries matching the query and/or kind.
Query is a case-insensitive substring match on title, description, author, or tags.
Kind is either "skill", "mcp", or None for both.
"""
items = load_catalogue()
if not query and not kind:
return items
q = query.lower()
results: List[MarketplaceItem] = []
for item in items:
if kind and item.type.value != kind:
continue
if q:
searchable = " ".join([
item.title,
item.description,
item.author,
" ".join(item.tags),
]).lower()
if q not in searchable:
continue
results.append(item)
return results
# ----------------------------------------------------------------------
# Default catalogue (built-in fallback)
# ----------------------------------------------------------------------
def _default_catalogue() -> List[MarketplaceItem]:
"""A small starter catalogue so the marketplace works out of the box."""
return [
MarketplaceItem(
id="filesystem",
name="filesystem",
type=MarketplaceItemType.MCP_SERVER,
title="Local Filesystem",
description="Provides read/write access to the local filesystem via MCP.",
author="modelprotocol",
source="https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem",
entry={
"mcp": {
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
}
}
},
tags=["filesystem", "storage", "essential"],
version="0.1.0",
license="MIT"
),
MarketplaceItem(
id="git",
name="git",
type=MarketplaceItemType.MCP_SERVER,
title="Git MCP Server",
description="Lets agents inspect and modify Git repositories through MCP.",
author="modelprotocol",
source="https://github.com/modelcontextprotocol/servers/tree/main/src/git",
entry={
"mcp": {
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git"]
}
}
},
tags=["git", "version-control", "development"],
version="0.1.0",
license="MIT"
),
MarketplaceItem(
id="github",
name="github",
type=MarketplaceItemType.MCP_SERVER,
title="GitHub MCP Server",
description="Provides read/write access to GitHub repositories, issues, and pull requests.",
author="modelprotocol",
source="https://github.com/modelcontextprotocol/servers/tree/main/src/github",
entry={
"mcp": {
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
}
}
},
tags=["github", "ci", "collaboration"],
version="0.1.0",
license="MIT"
),
MarketplaceItem(
id="brave-search",
name="brave-search",
type=MarketplaceItemType.MCP_SERVER,
title="Brave Search MCP Server",
description="Web search via Brave's search API with MCP.",
author="ModelContextProtocol",
source="https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search",
entry={
"mcp": {
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"]
}
}
},
tags=["search", "web", "research"],
version="0.1.0",
license="MIT"
),
MarketplaceItem(
id="filesystem-readonly",
name="filesystem-readonly",
type=MarketplaceItemType.MCP_SERVER,
title="Read-Only Filesystem",
description="Provides read-only access to the local filesystem via MCP.",
author="modelprotocol",
source="https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem",
entry={
"mcp": {
"config": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "--readonly", "."]
}
}
},
tags=["filesystem", "storage", "readonly", "safe"],
version="0.1.0",
license="MIT"
),
MarketplaceItem(
id="think",
name="think",
type=MarketplaceItemType.SKILL,
title="Think Tool",
description="A skill that makes the agent pause and reason aloud before acting.",
author="agentux-community",
source="https://github.com/agentux-community/skills/tree/main/think",
entry={
"skill": {
"module": "agentux_community.skills.think:think_skill",
"args": ""
}
},
tags=["reasoning", "planning", "cognitive"],
version="1.0.0",
license="MIT"
),
MarketplaceItem(
id="todo",
name="todo",
type=MarketplaceItemType.SKILL,
title="Todo List Skill",
description="Provides persistent todo list capabilities through a simple skill interface.",
author="agentux-community",
source="https://github.com/agentux-community/skills/tree/main/todo",
entry={
"skill": {
"module": "agentux_community.skills.todo:todo_skill",
"args": ""
}
},
tags=["productivity", "organization", "task-management"],
version="1.0.0",
license="MIT"
)
]
class Marketplace:
"""Main marketplace class for managing skills and MCP servers."""
def __init__(self):
"""Initialize the marketplace."""
self._items: List[MarketplaceItem] = []
self._load_items()
def _load_items(self) -> None:
"""Load items from catalogue and update installation status."""
# Load catalogue directly from disk, never through load_catalogue() --
# that function builds a Marketplace instance, which would recurse.
catalogue_items = _load_catalogue_items()
# If catalogue is empty, seed with default items
if not catalogue_items:
catalogue_items = _default_catalogue()
_save_catalogue_to_disk(catalogue_items)
# Load installed status
installed_names = set(_load_installed_from_disk())
# Update items with installation status
self._items = []
for item in catalogue_items:
# Create a copy with updated installation status
item_dict = item.to_dict()
item_dict['installed'] = item.name in installed_names
# Always reset enabled status when loading - it will be set based on actual configuration
item_dict['enabled'] = False
self._items.append(MarketplaceItem.from_dict(item_dict))
# Sort by name for consistent ordering
self._items.sort(key=lambda x: x.name)
def get_items_by_type(self, item_type: MarketplaceItemType) -> List[MarketplaceItem]:
"""Get items by type."""
return [item for item in self._items if item.type == item_type]
def search_items(self, query: str) -> List[MarketplaceItem]:
"""Search items by query."""
return search_catalogue(query)
def get_item(self, item_id: str) -> Optional[MarketplaceItem]:
"""Get item by ID."""
for item in self._items:
if item.id == item_id:
return item
return None
def install_item(self, item_id: str) -> bool:
"""Install an item."""
item = self.get_item(item_id)
if not item:
return False
if install_entry(item.name):
item.installed = True
self._save_items()
return True
return False
def uninstall_item(self, item_id: str) -> bool:
"""Uninstall an item."""
item = self.get_item(item_id)
if not item:
return False
if uninstall_entry(item.name):
item.installed = False
item.enabled = False # Disable when uninstalling
self._save_items()
return True
return False
def enable_item(self, item_id: str) -> bool:
"""Enable an item."""
item = self.get_item(item_id)
if not item or not item.installed:
return False
item.enabled = True
self._save_items()
return True
def disable_item(self, item_id: str) -> bool:
"""Disable an item."""
item = self.get_item(item_id)
if not item:
return False
item.enabled = False
self._save_items()
return True
def is_installed(self, item_id: str) -> bool:
"""Check if item is installed."""
item = self.get_item(item_id)
return item is not None and item.installed
def is_enabled(self, item_id: str) -> bool:
"""Check if item is enabled."""
item = self.get_item(item_id)
return item is not None and item.enabled
def get_installed_items(self) -> List[MarketplaceItem]:
"""Get all installed items."""
return [item for item in self._items if item.installed]
def get_enabled_items(self) -> List[MarketplaceItem]:
"""Get all enabled items."""
return [item for item in self._items if item.enabled]
def _save_items(self) -> None:
"""Save current items to catalogue."""
_save_catalogue_to_disk(self._items)
@property
def items(self) -> List[MarketplaceItem]:
"""Get all marketplace items."""
return self._items.copy()
def populate_default_items(self) -> None:
"""Populate the marketplace with default items if empty."""
if not self._items:
default_items = _default_catalogue()
installed_names = set(load_installed())
# Update with installation status
for item in default_items:
item.installed = item.name in installed_names
self._items = default_items
save_catalogue(self._items)
# Backwards compatibility functions - delegate to marketplace instance
_default_marketplace: Optional[Marketplace] = None
def _get_default_marketplace() -> Marketplace:
"""Get or create the default marketplace instance."""
global _default_marketplace
if _default_marketplace is None:
_default_marketplace = Marketplace()
return _default_marketplace
def load_catalogue() -> List[MarketplaceEntry]:
"""Load the marketplace catalogue from disk.
Returns a list of MarketplaceEntry objects for backwards compatibility.
"""
marketplace = _get_default_marketplace()
# Convert MarketplaceItem to MarketplaceEntry for backwards compatibility
entries = []
for item in marketplace.items:
entry_dict = item.to_dict()
# Remove the 'type' field and add 'kind' field for MarketplaceEntry
entry_dict.pop('type', None)
entry_dict['kind'] = item.type.value
entries.append(MarketplaceEntry.from_dict(entry_dict))
return entries
def save_catalogue(entries: List[MarketplaceEntry]) -> None:
"""Overwrite the catalogue with the given entries."""
marketplace = _get_default_marketplace()
# Convert MarketplaceEntry to MarketplaceItem
items = []
for entry in entries:
entry_dict = entry.to_dict()
# Convert kind to type for MarketplaceItem
entry_dict.pop('kind', None)
if 'type' not in entry_dict:
entry_dict['type'] = MarketplaceItemType.SKILL # Default to skill
items.append(MarketplaceItem.from_dict(entry_dict))
marketplace._items = items
marketplace._save_items()
def load_installed() -> List[str]:
"""Return the list of entry names the user has installed."""
return _load_installed_from_disk()
def save_installed(names: List[str]) -> None:
"""Overwrite the installed list with the given names."""
_save_installed_to_disk(names)
def install_entry(name: str) -> bool:
"""Mark an entry as installed; returns True if the name was not already present."""
installed = _load_installed_from_disk()
if name in installed:
return False
installed.append(name)
_save_installed_to_disk(installed)
return True
def uninstall_entry(name: str) -> bool:
"""Mark an entry as uninstalled; returns True if the name was present."""
installed = _load_installed_from_disk()
if name not in installed:
return False
installed.remove(name)
_save_installed_to_disk(installed)
return True
def is_installed(name: str) -> bool:
"""Check whether an entry is marked as installed."""
return name in _load_installed_from_disk()
def search_catalogue(query: str = "", kind: Optional[str] = None) -> List[MarketplaceEntry]:
"""Return catalogue entries matching the query and/or kind.
Query is a case-insensitive substring match on title, description, author, or tags.
Kind is either "skill", "mcp", or None for both.
Returns a list of MarketplaceEntry objects for backwards compatibility.
"""
marketplace = _get_default_marketplace()
items = marketplace.items
if not query and not kind:
# Convert to MarketplaceEntry for backwards compatibility
entries = []
for item in items:
entry_dict = item.to_dict()
entry_dict.pop('type', None)
entry_dict['kind'] = item.type.value
entries.append(MarketplaceEntry.from_dict(entry_dict))
return entries
q = query.lower()
results: List[MarketplaceEntry] = []
for item in items:
if kind and item.type.value != kind:
continue
if q:
searchable = " ".join([
item.title,
item.description,
item.author,
" ".join(item.tags),
]).lower()
if q not in searchable:
continue
# Convert to MarketplaceEntry for backwards compatibility
entry_dict = item.to_dict()
entry_dict.pop('type', None)
entry_dict['kind'] = item.type.value
results.append(MarketplaceEntry.from_dict(entry_dict))
return results
def seed_catalogue() -> None:
"""Populate the marketplace directory with the default catalogue if empty."""
marketplace = _get_default_marketplace()
marketplace.populate_default_items()
# Legacy functions for backwards compatibility
def load_catalogue_legacy() -> List[Dict[str, Any]]:
"""Legacy function for backwards compatibility."""
# Create a temporary marketplace instance to avoid recursion
marketplace_temp = Marketplace.__new__(Marketplace)
marketplace_temp._items = [] # Initialize empty items
# Manually load catalogue items without triggering full initialization
catalogue_items = load_catalogue()
if not catalogue_items:
catalogue_items = _default_catalogue()
# Convert to legacy format
return [item.to_dict() for item in catalogue_items]
def save_catalogue_legacy(entries: List[Dict[str, Any]]) -> None:
"""Legacy function for backwards compatibility."""
marketplace = _get_default_marketplace()
items = [MarketplaceItem.from_dict(entry) for entry in entries]
marketplace._items = items
marketplace._save_items()
def load_installed_legacy() -> List[str]:
"""Legacy function for backwards compatibility."""
return load_installed()
def save_installed_legacy(names: List[str]) -> None:
"""Legacy function for backwards compatibility."""
save_installed(names)
def install_entry_legacy(name: str) -> bool:
"""Legacy function for backwards compatibility."""
return install_entry(name)
def uninstall_entry_legacy(name: str) -> bool:
"""Legacy function for backwards compatibility."""
return uninstall_entry(name)
def is_installed_legacy(name: str) -> bool:
"""Legacy function for backwards compatibility."""
return is_installed(name)
def search_catalogue_legacy(query: str = "", kind: Optional[str] = None) -> List[Dict[str, Any]]:
"""Legacy function for backwards compatibility."""
items = search_catalogue(query, kind)
return [item.to_dict() for item in items]
def seed_catalogue_legacy() -> None:
"""Legacy function for backwards compatibility."""
marketplace = _get_default_marketplace()
marketplace.populate_default_items()
def fetch_skills_from_sh() -> List[MarketplaceItem]:
"""Fetch skills from skills.sh (local file or URL).
Attempts to load skills from a skills.sh file which should output
skill definitions in a format compatible with MarketplaceItem.
Returns:
List of MarketplaceItem objects representing skills, or empty list if failed.
"""
import subprocess
import json
try:
# Try to run skills.sh as a script and capture output
# Assuming it outputs JSON format that can be parsed
result = subprocess.run(
['bash', 'skills.sh'],
capture_output=True,
text=True,
timeout=30
)
if result.returncode == 0 and result.stdout.strip():
# Try to parse as JSON
try:
data = json.loads(result.stdout)
# Convert to MarketplaceItem objects
items = []
if isinstance(data, list):
for skill_data in data:
if isinstance(skill_data, dict):
# Create a MarketplaceItem from the skill data
item = MarketplaceItem(
id=skill_data.get('id', skill_data.get('name', 'unknown')),
name=skill_data.get('name', 'unknown'),
type=MarketplaceItemType.SKILL, # Assuming skills.sh contains skills
title=skill_data.get('title', skill_data.get('name', 'Unknown Skill')),
description=skill_data.get('description', ''),
author=skill_data.get('author', 'unknown'),
source=skill_data.get('source', ''),
entry=skill_data.get('entry', {"skill": {"module": "", "args": ""}}),
tags=skill_data.get('tags', []),
version=skill_data.get('version', '1.0.0'),
license=skill_data.get('license', 'MIT')
)
items.append(item)
return items
except json.JSONDecodeError:
# If not JSON, try to parse as simple format
pass
except Exception:
# Failed to fetch from skills.sh
pass
return []
def fetch_mcps_from_website() -> List[MarketplaceItem]:
"""Fetch MCP servers from mcpmarketplace.com.
Attempts to load MCP server information from mcpmarketplace.com.
Returns:
List of MarketplaceItem objects representing MCP servers, or empty list if failed.
"""
try:
# Use the WebFetch tool equivalent - in a real implementation,
# this would make an HTTP request to mcpmarketplace.com
# For now, we'll return an empty list as a placeholder
# In a production environment, this would parse the website or API
return []
except Exception:
# Failed to fetch from mcpmarketplace.com
pass
return []
def _fetch_and_merge_external_items(self) -> None:
"""Fetch items from external sources and merge with existing catalogue.
This method fetches skills from skills.sh and MCPs from mcpmarketplace.com,
then merges them with the existing catalogue items.
"""
# Fetch skills from skills.sh
external_skills = fetch_skills_from_sh()
# Fetch MCPs from mcpmarketplace.com
external_mcps = fetch_mcps_from_website()
# Combine all external items
external_items = external_skills + external_mcps
if not external_items:
return # No external items to add
# Get current items and installed status to preserve it
current_items = self._items
installed_names = {item.name for item in current_items if item.installed}
# Merge external items with current items, avoiding duplicates by name/id
merged_items = []
existing_ids = {item.id for item in current_items}
existing_names = {item.name for item in current_items}
# Add current items first
merged_items.extend(current_items)
# Add external items that don't already exist
for item in external_items:
if item.id not in existing_ids and item.name not in existing_names:
# Preserve installed status if this item was previously installed
item.installed = item.name in installed_names
merged_items.append(item)
existing_ids.add(item.id)
existing_names.add(item.name)
# Update the items list and save
self._items = merged_items
self._items.sort(key=lambda x: x.name)
save_catalogue(self._items)
# Update the Marketplace class to call external fetch during initialization
# Uncomment the following line in _load_items to enable automatic fetching:
# self._fetch_and_merge_external_items()
__all__ = [
"MarketplaceEntry",
"MarketplaceItem",
"MarketplaceItemType",
"Marketplace",
# Legacy functions for backwards compatibility
"load_catalogue_legacy",
"save_catalogue_legacy",
"load_installed_legacy",
"save_installed_legacy",
"install_entry_legacy",
"uninstall_entry_legacy",
"is_installed_legacy",
"search_catalogue_legacy",
"seed_catalogue_legacy",
# External fetch functions
"fetch_skills_from_sh",
"fetch_mcps_from_website",
]
|