Skip to content

feat(mcp): align energy purchase, security, and agent output - #30

Merged
bbsyaya merged 15 commits into
justlend:mainfrom
BlackChar92:feat/energy-direct-purchase
Aug 28, 2026
Merged

feat(mcp): align energy purchase, security, and agent output#30
bbsyaya merged 15 commits into
justlend:mainfrom
BlackChar92:feat/energy-direct-purchase

Conversation

@BlackChar92

@BlackChar92 BlackChar92 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Scope

This is the single MCP PR for the coordinated open-source release. It combines energy direct purchase, security remediation, and AI readability in one review.

1. Energy direct purchase

  • add six tools: get_energy_purchase_config, quote_energy_purchase, get_energy_purchase_order, get_energy_purchase_history, get_energy_payment_risk, and buy_energy_direct
  • use the app's trusted production endpoint by default: https://tegrow.ablesdxd.link
  • prevent the production API from being paired with a non-mainnet signer
  • normalize live config/quote fields and bind payment confirmation to the exact authoritative quote
  • expose public payer history for in-progress and settled orders
  • return tokenless idempotent orders immediately instead of polling without credentials; retain recovery state until history confirms the payment/order

2. Security audit remediation

  • serialize payer intents and shared risk-state mutations across processes
  • persist sensitive local state atomically with owner-only permissions
  • reject redirects so signed payments and order tokens cannot be forwarded to another origin
  • redact replayable payment data from MCP output
  • require solidified chain success before creating another order
  • disable the legacy unauthenticated browser-wallet bridge; supported writes use encrypted agent-wallet
  • document that an ambiguous result may retain the exact signed request in the local mode-0600 risk file until reconciliation
  • refresh dependency pins; production and development audits are clean

3. AI readability

  • declare a common MCP outputSchema for all 104 tools
  • return versioned structuredContent while preserving legacy text content
  • regenerate the complete 104-tool catalog with input/output schemas and side-effect metadata
  • reconcile the public inventory to 24 markets: 18 active + 6 legacy, including active jU

Validation

  • npm test502 passed, 19 skipped
  • npm run build — passed
  • npm run gen:api-list — deterministic; 104 tool headings and 104 output schemas
  • energy regressions cover redirect blocking, public history pagination, and tokenless idempotent recovery
  • live read-only production smoke — config and a 65,000-energy quote passed without an endpoint override
  • Nile agent-wallet E2E — order e03fdbf3-df94-42e0-992d-374390902318 delivered; payment 43a9cdcc…44848 solidified; EnergyLimit +65,000; 0 unresolved risks
  • npm audit --audit-level=high — 0 vulnerabilities
  • npm pack --dry-run — v1.1.3 package contains the generated catalog

No mainnet payment was signed or broadcast during self-test.

Runtime boundary

The MCP server signs the native TRX payment; the configured backend validates and may broadcast it. Economic limits, price, payment address, and pool capacity always come from live responses. Custom/test endpoints require explicit configuration and trust opt-in; the production endpoint is rejected with non-mainnet signers.

Coordinated rollout

Surface PR Candidate
CLI justlend-cli#2 v1.0.1
MCP mcp-server-justlend#30 v1.1.3
Skills justlend-skills#8 v1.1.1
Docs justlend-docs#102 coordinated docs

Docs may merge first. The CLI, MCP, and Skills PRs should follow in the same release window so public contracts do not remain ahead of implementation.

- expose config, quote, order, history, risk, and confirmed buy tools
- keep payment broadcast server-side with same-transaction retries
- persist reconciliation markers and document the tool workflow
- Acquire payer-scoped process and filesystem intents before signing.
- Fail closed on corrupt risk state and require exact quote confirmation.
- Upgrade PostCSS and add security regression coverage.
- Lock shared risk-store mutations across processes.
- Refresh vulnerable dependency pins and cover write contention.
- align quote, payment, memo, and response handling with the live API\n- preserve ambiguous payments for exact replay and bind network, recipient, and signer output\n- disable the unauthenticated browser-wallet bridge and remove its dependency\n- redact replayable payment data from MCP responses and add regression coverage
- Observe FullNode receipts before checking SolidityNode finality
- Persist chain status without reopening ambiguous payment risks
- Expose the staged result and cover reconciliation with tests
- Keep wallet selection and caches scoped to the active MCP session.
- Serialize stale intent recovery with the payment-risk mutation lock.
- Guard intent ownership checks and deletion with the shared mutation lock.\n- Persist signed payment risk without recursively acquiring the store lock.\n- Cover release and finalize lock ownership with regression tests.
- Declare a versioned output schema for all 98 tools.\n- Preserve legacy text content while exposing structuredContent.\n- Reconcile the documented market roster to 24 markets.
- Remove trailing Markdown spaces from generated tool titles.\n- Keep regenerated catalogs clean under git diff checks.
# Conflicts:
#	mcp-api-list.md
#	package.json
- Route post-purchase tracking through order lookup.
- Direct uncertain payments to the existing risk reconciliation tool.
@BlackChar92 BlackChar92 changed the title feat(mcp): add secure energy purchases and structured outputs feat(mcp): align energy purchase, security, and agent output Aug 20, 2026
- default to the app release's trusted production endpoint\n- normalize live config, quote, purchase, and recovery fields\n- prevent production API use with non-mainnet signing
- reject redirects for signed payments and order credentials
- add public payer history as the sixth purchase tool
- retain signed recovery state until history confirms the order
- keep the read-only payment-risk tool bound to the configured wallet\n- suggest exact vault approval amounts instead of unlimited allowance\n- reject invalid token decimals before scaling market transactions
@bbsyaya
bbsyaya merged commit 7d53a6c into justlend:main Aug 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants