tokrepo-mcp-server 2.6.0 → 2.7.0

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.
Files changed (3) hide show
  1. package/README.md +11 -0
  2. package/bin/server.js +61 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -42,6 +42,7 @@ Once connected, your AI assistant can:
42
42
  - **Plan before install** — get install plan v2 with policy decisions, rollback, and verification
43
43
  - **Safe Codex install** — dry-run by default; risky assets must be staged or explicitly approved
44
44
  - **Lifecycle control** — list, update, uninstall, and roll back managed Codex installs
45
+ - **Project memory** — pair with `tokrepo init-agent --target all` so future agents know to call TokRepo during planning
45
46
 
46
47
  ## Available Tools
47
48
 
@@ -73,6 +74,16 @@ AI: [calls tokrepo_codex_install with dry_run=false, confirm=true] → Writes on
73
74
  AI: [calls tokrepo_rollback with dry_run=true] → Shows exactly what would be removed before rollback
74
75
  ```
75
76
 
77
+ ## Make Future Agents Discover TokRepo
78
+
79
+ Run this once in a project:
80
+
81
+ ```bash
82
+ npx tokrepo init-agent --target all
83
+ ```
84
+
85
+ It writes managed instructions to `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, Cursor rules, and `.mcp.json`. The rule is simple: during planning, when the agent sees a capability gap, it should call `tokrepo_discover` before inventing a one-off local tool. After a task, agents can run `tokrepo agent-handoff --json` to suggest reusable files for user-confirmed private publishing.
86
+
76
87
  ## Why TokRepo?
77
88
 
78
89
  TokRepo is the **open registry for AI assets** — like npm for packages, but for AI skills, prompts, MCP configs, and workflows.
package/bin/server.js CHANGED
@@ -19,7 +19,7 @@ const API_BASE = process.env.TOKREPO_API || 'https://api.tokrepo.com';
19
19
  const TOKREPO_URL = 'https://tokrepo.com';
20
20
  const TOKREPO_TOKEN = process.env.TOKREPO_TOKEN || '';
21
21
  const TOKREPO_CLI = process.env.TOKREPO_CLI || '';
22
- const SERVER_VERSION = '2.6.0';
22
+ const SERVER_VERSION = '2.7.0';
23
23
 
24
24
  // ─── MCP Protocol (JSON-RPC over stdio) ───
25
25
 
@@ -701,7 +701,60 @@ function buildDiscoveryQuery(task, environment, constraints) {
701
701
  return compactText([...new Set(parts)].join(' '), 100);
702
702
  }
703
703
 
704
- function buildCandidate(item, target) {
704
+ function scoreDiscoveryCandidate(item, task, target, constraints = {}) {
705
+ const metadata = itemAgentMetadata(item);
706
+ const fit = itemAgentFit(item);
707
+ const tags = itemTags(item);
708
+ const targets = candidateTargets(item, metadata);
709
+ const terms = extractSearchTerms(task, 10);
710
+ const haystack = [
711
+ item.title,
712
+ item.description,
713
+ tags.join(' '),
714
+ metadata.entrypoint,
715
+ metadata.asset_kind,
716
+ ].filter(Boolean).join(' ').toLowerCase();
717
+ let score = Number.isFinite(Number(fit.score)) ? Number(fit.score) : 45;
718
+ const reasons = [];
719
+ const matched = terms.filter(term => haystack.includes(term));
720
+ if (matched.length) {
721
+ score += Math.min(24, matched.length * 4);
722
+ reasons.push(`task term match: ${matched.slice(0, 5).join(', ')}`);
723
+ }
724
+ if (target && target !== 'any') {
725
+ if (targets.includes(target) || fit.target === target) {
726
+ score += 12;
727
+ reasons.push(`target matches ${target}`);
728
+ } else if (targets.length) {
729
+ score -= 10;
730
+ reasons.push(`target metadata is ${targets.join(', ')}`);
731
+ }
732
+ }
733
+ const kind = candidateKind(item, metadata, fit);
734
+ if (constraints.kind && String(kind).toLowerCase() === String(constraints.kind).toLowerCase()) {
735
+ score += 8;
736
+ reasons.push(`kind matches ${constraints.kind}`);
737
+ }
738
+ const policy = fit.policy || item.policy || '';
739
+ if (policy === 'allow') {
740
+ score += 6;
741
+ reasons.push('policy allow');
742
+ } else if (policy === 'deny') {
743
+ score -= 35;
744
+ reasons.push('policy deny');
745
+ } else if (policy === 'stage_only' || policy === 'confirm') {
746
+ score -= 6;
747
+ reasons.push(`policy ${policy}`);
748
+ }
749
+ const trust = item.trust || item.agent_trust || {};
750
+ if (trust.review_status === 'reviewed' || trust.verified_publisher) {
751
+ score += 4;
752
+ reasons.push('reviewed or verified');
753
+ }
754
+ return { score: Math.max(0, Math.min(100, Math.round(score))), reasons };
755
+ }
756
+
757
+ function buildCandidate(item, target, ranking = {}) {
705
758
  const uuid = candidateUuid(item);
706
759
  const metadata = itemAgentMetadata(item);
707
760
  const fit = itemAgentFit(item);
@@ -734,6 +787,7 @@ function buildCandidate(item, target) {
734
787
  policy: compactText(fit.policy || item.policy || '', 64),
735
788
  why,
736
789
  },
790
+ ranking,
737
791
  next_mcp_calls: [
738
792
  { tool: 'tokrepo_detail', arguments: { uuid } },
739
793
  { tool: 'tokrepo_install_plan', arguments: { uuid, target: planTarget } },
@@ -832,7 +886,11 @@ async function handleDiscover(args) {
832
886
  'Use the installed capability only for the matching subtask, then verify the user goal.',
833
887
  'If the agent creates a reusable improvement, ask before publishing and use tokrepo_push with explicit files.',
834
888
  ],
835
- candidates: items.slice(0, limit).map(item => buildCandidate(item, target)).filter(candidate => candidate.uuid),
889
+ candidates: items
890
+ .map(item => buildCandidate(item, target, scoreDiscoveryCandidate(item, task, target, constraints)))
891
+ .filter(candidate => candidate.uuid)
892
+ .sort((a, b) => (b.ranking?.score || 0) - (a.ranking?.score || 0))
893
+ .slice(0, limit),
836
894
  empty_state: items.length ? null : {
837
895
  message: discoveryError
838
896
  ? `TokRepo discovery could not fetch live candidates for "${selectedQuery}".`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokrepo-mcp-server",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Agent-native MCP server for TokRepo — search, plan, safely install, and push AI assets from MCP clients.",
5
5
  "mcpName": "io.github.tokrepo/mcp-server",
6
6
  "bin": {