Skip to content

[DMP 2026]: Finternet: MCP Server for UNITS API — Agentic Tooling and Gap Remediation #749

Open

Description

@vineet-finternet

Ticket Contents

Description

The Model Context Protocol (MCP) is rapidly becoming the standard integration layer for AI agents interacting with external services. Finternet's UNITS system — with its delegation-scoped account model, programmable token operations, and credential-gated transfers — is a natural fit for agentic execution: recurring payments, conditional transfers, cross-border routing, and portfolio operations all benefit from agent-driven automation without requiring real-time user approval per operation.
An initial MCP server for the UNITS API exists but has known gaps in tool coverage, error handling, and agentic workflow support. This project has two workstreams: (1) audit and remediate existing MCP server gaps, and (2) design and implement delegation-scoped agentic workflow tools that expose UNITS' programmable delegation model to AI agents in a safe, policy-bound way.

Goals & Mid-Point Milestone

Goals

  • Workstream 1 — Conduct a systematic audit of the existing UNITS MCP server against the full UNITS App API surface. For each gap, produce one of:
    • A new MCP tool implementation
    • A documented limitation with rationale (e.g., operations that should not be exposed via MCP for security reasons)
    • A fix to an existing tool (error handling, schema correctness, response formatting)
  • Workstream 2 — Design and implement MCP tools that expose UNITS' delegation model to agents safely. All agent-initiated operations must present a valid delegation credential chain; UNITS enforces scope at execution time. Tools to implement:
    • get_account_summary — returns unified token holdings (native + proxy), active delegations, and credential store summary for the delegating account; respects delegation scope
    • initiate_transfer — initiates a token transfer within the agent's delegated scope (token class, amount limit, frequency limit enforced); returns pre-flight policy evaluation result before committing
    • check_transfer_eligibility — dry-run transfer policy evaluation without committing; returns which dependency pointers passed/failed and which credentials were checked
    • get_delegation_scope — returns the agent's current delegation credential with scope constraints; allows an agent to self-check before attempting an out-of-scope operation
    • subscribe_lifecycle_events — subscribes the agent to UNITS lifecycle events (transfer committed, credential expired, dependency pointer state changed) relevant to the delegating account, within delegated scope
    • present_credential_vp — constructs and submits a Verifiable Presentation from the account's credential store to satisfy a transfer policy credential requirement; agent does not see raw credential values
  • Agentic safety constraints:
    • No MCP tool may expose a raw private key or credential claim value to the agent
    • initiate_transfer always returns a pre-flight eligibility check result before committing; agents cannot skip the pre-flight
    • All tool calls are logged with the agent's Finternet account address
    • Scope violations return a structured SCOPE_EXCEEDED error, not a generic failure
  • Goals Achieved By Mid-point Milestone: get_account_summary, check_transfer_eligibility, and get_delegation_scope tools implemented and tested.

Setup/Installation

Builds on the existing UNITS MCP server codebase. MCP SDK for tool definitions and server scaffolding. Local development against a Docker Compose UNITS dev environment. Integration tests using the MCP Inspector tool and a test AI agent harness (e.g., Claude via the Anthropic API with tool use).

Expected Outcome

No response

Acceptance Criteria

No response

Implementation Details

  • MCP SDK: Any conformant MCP SDK may be used (reference implementations exist in TypeScript, Python, and Rust — contributor to select based on UNITS codebase language and justify the choice); all tools defined with full JSON Schema input/output specs regardless of implementation language
  • Auth: All MCP tool calls carry a delegation credential chain in the request context; UNITS validates the chain before executing any operation
  • Error schema: All UNITS MCP tool errors return {code: string, message: string, detail: object} where code is one of a defined enum, where code is appropriately defined enum
  • Testing: Three levels required — (1) unit tests per tool against a mock UNITS server, (2) integration tests covering full request-response cycles against a dev UNITS instance, (3) end-to-end agentic workflow tests using an AI agent client exercising ≥2 complete delegation-scoped workflows. Contributor to propose specific tooling in their implementation plan.

Mockups/Wireframes

No response

Product Name

UNITS MCP Server — Agentic Tooling and Gap Remediation

Organisation Name

FinternetLabs

Domain

Financial Inclusion

Tech Skills Needed

Other

Mentor(s)

Will be assigned from the Finternet engineering team

Category

Backend, AI

Activity

  1. Rahul-2k4 commented on Mar 18, 2026

    @Rahul-2k4

    Hi @vineet-finternet I’m interested in working on this for C4GT 2026 and wanted to understand the contribution path a bit better before I start.

    A few quick questions:

    1. Which public repository contains the current UNITS MCP server implementation?
    2. Are pre-application contributions/PRs welcome in that repo for this project?
    3. What language is the current MCP server implemented in, or is the contributor expected to choose the implementation language?
    4. Is there any existing API coverage checklist / roadmap for the current MCP server so
      contributors can identify the missing tool surface systematically?
    5. Are there any public docs or repo(s) for the UNITS App API and delegation model that you recommend reading first?

    I’ve started reviewing the public Finternet repos and issue details, and I’d like to align
    early with the right repo and expected workflow.

    Thanks.

  2. Varadraj75 commented on Mar 20, 2026

    @Varadraj75

    Hi @vineet-finternet i am interested in picking this up for C4GT 2026.
    The plan is to start with a full audit of the existing MCP server against the UNITS API surface, then move into Workstream 2-get_account_summary, check_transfer_eligibility, and get_delegation_scope-to hit the midpoint milestone. I'll wire up unit → integration → e2e test coverage as I go, not after.
    Before I start: which repo holds the current MCP server? Has the implementation language been decided, or is that for the contributor to justify?

  3. Rahul-2k4 commented on Mar 20, 2026

    @Rahul-2k4

    Hey @Varadraj75 , can u please work on some other issue , i have already been doing some work on it , so just in case not waste each other efforts . Thanks

  4. praveenjha527 commented on Mar 21, 2026

    @praveenjha527

    @Rahul-2k4 Thanks for your interest in contributing to this project for C4GT 2026. Here are the answers
    to your questions:

    Which public repository contains the current UNITS MCP server implementation?

    • The repository is currently not public.

    Are pre-application contributions/PRs welcome in that repo for this project?

    • Yes, pre-application contributions and PRs are welcome.

    What language is the current MCP server implemented in, or is the contributor expected to choose the implementation language?

    • You are free to choose the language of your choice for the implementation.

    Is there any existing API coverage checklist / roadmap for the current MCP server so contributors can identify the missing tool surface systematically?

    • Yes, there is an API available for UNITS Open that you can refer to for coverage. We will publish the openapispec.

    Are there any public docs or repo(s) for the UNITS App API and delegation model that you recommend reading first?

  5. Rahul-2k4 commented on Mar 21, 2026

    @Rahul-2k4

    Hi @praveenjha527, thanks for the clarification.
    I’ve started working through Issue #749 from the public docs and issue details, and I’m preparing a docs-based audit/ implementation plan so I can move quickly on the right surface.

    Since the current MCP server repo is not public yet, could you please share the best next contribution entry point when available, whether that is:

    • the MCP server repository
    • the UNITS OpenAPI spec
    • or any public draft interface/repo contributors should align against first

    I’d like to contribute against the intended implementation surface rather than make assumptions and drift from the design.
    thank you

  6. mn-ram commented on Mar 21, 2026

    @mn-ram

    Hi @vineet-finternet and @praveenjha527,

    I've gone through the issue description carefully and explored the Finternet docs at https://docs.finternetlab.io/. I had a few specific questions before I begin structuring my implementation plan:

    • For Workstream 1 (audit): once the OpenAPI spec is published, should the audit output be a structured document (e.g., a markdown table mapping each endpoint to: covered / not covered / intentionally excluded), or is there a preferred format from the Finternet team?

    • For the initiate_transfer tool: the issue mentions a pre-flight eligibility check before committing. Should this pre-flight internally call check_transfer_eligibility as a reusable function, or should both tools independently call the UNITS policy evaluation endpoint?

    • For language choice: is the existing (private) MCP server in TypeScript? I want to align with the existing codebase language rather than introduce a different one.

    I'll begin with the docs-based audit of the UNITS API surface while the repo is being made ready.

  7. ChayanDass commented on Mar 23, 2026

    @ChayanDass

    @vineet-finternet, @praveenjha527,
    I am interested in this project as it aligns with my current interests.
    I look forward to contributing.

  8. dreamweaver19 commented on Mar 31, 2026

    @dreamweaver19

    Hi @vineet-finternet,

    I am very interested in drafting a proposal for this DMP 2026 project! The intersection of agentic workflows and the UNITS delegation model looks like a fantastic challenge.

    I would love to get a head start on Workstream 1 (conducting the systematic audit). Could you please share the link to the repository containing the initial UNITS MCP server mentioned in the description?

    Thank you!

  9. shrutisachan08 commented on Apr 1, 2026

    @shrutisachan08

    Hi @vineet-finternet ,
    The given project aligns well with my domain . Hence I would like start with workstream 1 . Could please the link to repository or guide me where to begin my contribution.

  10. kashyapanish6373-cyber commented on Apr 1, 2026

    @kashyapanish6373-cyber

    Hi @kashyapanish6373
    I am excited to apply for the UNITS MCP Server — Agentic Tooling and Gap Remediation project by FinternetLabs. This project sits at the intersection of backend systems, AI agents, and financial infrastructure — an area I am deeply interested in.

    The opportunity to design secure, delegation-aware agentic workflows using the Model Context Protocol (MCP) aligns closely with my interests in building reliable, policy-driven systems. I am particularly motivated by the challenge of enabling AI agents to safely execute financial operations without compromising on security or user control.

  11. basant-gautam commented on Apr 2, 2026

    @basant-gautam

    Hi @vineet-finternet @praveenjha527,I am very interested in contributing to the UNITS MCP Server project for DMP 2026. Since the documentation link (https://docs.finternetlab.io/) is currently restricted (403 error), I have prepared an initial implementation strategy based on the issue description:Tech Stack & Language: I propose using TypeScript with the MCP SDK, as it provides excellent support for JSON Schema definitions which are required for all tool input/output specs.Workstream 1 (Audit): Once the OpenAPI spec is public, I plan to create a mapping table to identify gaps in the current MCP server, focusing on error handling and schema correctness.Workstream 2 (Agentic Tools): My focus for the mid-point milestone will be on:check_transfer_eligibility: Implementing this as a mandatory "dry-run" to return policy evaluation results (dependency pointers and credentials checked) before any actual commitment.get_delegation_scope: Ensuring agents can self-check their constraints to avoid SCOPE_EXCEEDED errors.Security First: I will ensure that no MCP tool exposes raw private keys or credential values, strictly following the agentic safety constraints mentioned.Testing Strategy: I plan to use Docker Compose for local UNITS environment testing and a test AI agent harness (like Claude) for end-to-end workflow validation.Looking forward to the public repository and OpenAPI spec to start the audit.Thanks!

  12. aniket866 commented on Apr 24, 2026

    @aniket866

    hi @vineet-finternet
    I would like to work on this
    Idea

    UNITS MCP Server — Agentic Tooling & Gap Remediation

    Approach (MVP Planning)

    1. Problem Understanding

    The existing MCP server for UNITS API is incomplete and lacks:

    • Full API coverage

    • Robust error handling

    • Agent-safe execution workflows

    Additionally, there is no structured support for delegation-based agent workflows.


    2. High-Level Strategy

    Split execution into two parallel workstreams:

    Workstream 1: MCP Server Audit & Fixes

    • Map all UNITS API endpoints

    • Compare with existing MCP tools

    • Identify gaps:

      • Missing tools

      • Broken implementations

      • Security-sensitive exclusions

    • Fix or document each gap

    Workstream 2: Agentic Workflow Tools

    • Design safe delegation-based tools

    • Enforce policy-bound execution

    • Implement core agent-facing tools


    3. Architecture Design

    Components

    • MCP Server (Tool Layer)

    • UNITS API Backend

    • Delegation Credential System

    • AI Agent Client

    Flow

    1. Agent sends MCP tool request

    2. Delegation credentials validated

    3. Policy scope checked

    4. Pre-flight validation executed

    5. Operation committed (if valid)

    6. Structured response returned


    4. Core Tools (Midpoint MVP)

    4.1 get_account_summary

    • Returns:

      • Token holdings

      • Delegations

      • Credential metadata

    • Scope-aware response

    4.2 check_transfer_eligibility

    • Dry-run transfer

    • Outputs:

      • Policy checks

      • Passed/failed constraints

      • Credential validation status

    4.3 get_delegation_scope

    • Returns:

      • Allowed token classes

      • Limits (amount/frequency)

      • Active credential scope


    5. Safety Design (Critical)

    • No raw credentials exposed

    • Mandatory pre-flight checks

    • Structured error handling:
      {code, message, detail}

    • Scope enforcement:

      • Return SCOPE_EXCEEDED

    • Full audit logging of tool calls


    6. Tech Stack

    • Language: TypeScript / Python (based on UNITS backend)

    • MCP SDK: Official SDK (TS/Python/Rust)

    • Backend: UNITS API

    • Testing:

      • Unit: Mock server

      • Integration: Docker UNITS

      • E2E: AI agent (Claude / similar)


    7. Testing Strategy

    Level 1: Unit Testing

    • Mock UNITS API

    • Validate each tool independently

    Level 2: Integration Testing

    • Full request-response cycles

    • Docker-based environment

    Level 3: Agent Workflow Testing

    • Multi-step flows:

      • Eligibility → Transfer → Event tracking


    8. Milestone Deliverables

    Midpoint

    • get_account_summary

    • check_transfer_eligibility

    • get_delegation_scope

    • Unit + Integration tests

    Final

    • Full MCP coverage

    • All agent tools implemented

    • Event subscription system

    • Credential presentation flow


    9. Expected Outcome

    • Secure MCP server with full API coverage

    • Delegation-safe AI agent execution

    • Production-ready agentic financial workflows


    10. Key Risks & Mitigation

    Risk | Mitigation -- | -- Security leaks | Strict credential abstraction Scope bypass | Enforced validation layer API mismatch | Automated audit mapping Agent misuse | Policy + pre-flight enforcement

    11. Summary

    This MVP focuses on building a secure, policy-driven MCP layer that enables AI agents to interact with UNITS safely using delegation-based execution, starting with audit + 3 core tools and expanding to full workflow automation.

  13. vyagh commented on Apr 25, 2026

    @vyagh

    Hii @praveenjha527 @vineet-finternet
    I have been reviewing the documentation and have some understanding of the project goals and plan now.
    I was seeking some clarification on the next steps. I noticed that pre contributions are welcome; should I contribute to the finternet repositories?
    Additionally, I checked the documentation for the UNITS GitHub repo, but the link is unreachable.

    Could you please provide guidance on the best way to proceed and contribute to the project?

  14. codewarnab commented on Apr 26, 2026

    @codewarnab

    Hi, I'm Arnab Mondal and I'd love to contribute to this project.

    I went through the Finternet overview and architecture docs — the delegation-scoped account model and how it maps to agentic execution is a really interesting problem, and something I'd genuinely enjoy working on.

    Some relevant things I've built:

    • Agentic Systems @ Codemate AI — Built agentic RAG pipelines, parallel tool-calling flows, and knowledge base chat with real-time tool orchestration during my internship. Write-up here.
    • Cognito AI — An agentic browser extension with MCP support, CLI integration, and multi-tool orchestration. More here.
    • Verida — Also built on Verida, which operates in a similar space around decentralized identity and credential-gated data — so the credential chain model in UNITS feels familiar.

    I've also contributed to a few open source projects in gen ai space — vercel/ai, supermemoryai/supermemory, and langfuse/langfuse.

    More of my work is at codewarnab.in if you want to take a look. Would love to be part of this.

  15. Jayant-kernel commented on Apr 29, 2026

    @Jayant-kernel

    Hi @vineet-finternet
    I've been going through the Finternet docs and the specs repo. A few specific questions on
    Workstream 1: Should the audit output be a structured markdown table mapping each UNITS API endpoint to covered/not-covered/intentionally-excluded?
    And for the MCP SDK choice — given UNITS uses TypeScript, should contributors align with TS or is Rust preferred for performance-critical tools like initiate_transfer?

  16. KalpanaBhaskar commented on May 2, 2026

    @KalpanaBhaskar

    Hi @vineet-finternet and @praveenjha527,
    I’ve been digging into the UNITS delegation model described in the issue. While the base tools cover the "mechanics" of execution, I believe a critical success factor for agentic financial workflows is handling Policy Friction ,specifically when an agent holds multiple delegation credentials with overlapping or conflicting constraints.
    To ensure the MCP server is production-ready, I’d like to propose two unique additions to my implementation plan:

    1. Policy Conflict Resolution Tool (debug_delegation_constraints)
      Currently, if a transfer fails with SCOPE_EXCEEDED, the agent hits a wall. I propose a tool that performs a diff between the requested action and the active delegation chain. Instead of just "No," the agent receives a reason (e.g., “Daily limit exceeded by $50” or “Invalid token class for this credential”), allowing it to autonomously adjust its strategy without human intervention.
    2. Agent Explainability via "Intent-Signed" Audit Trails
      I propose extending the initiate_transfer tool to accept an optional intent_manifest. This maps the agent’s internal reasoning (the "why") to the pre-flight result. When an account owner reviews tool logs, they won't just see a transaction—they'll see the logic the agent used to justify the move within its delegated scope.
      Technical Stack & Readiness:
      I’ll be using TypeScript with the official MCP SDK to leverage strict JSON Schema validation for the credential chains.
      I am ready to begin the Workstream 1 audit as soon as the OpenAPI spec and private repo access are provided.
      Looking forward to contributing to the Finternet ecosystem!
  17. Geetanjali015 commented on May 7, 2026

    @Geetanjali015

    Hi @vineet-finternet @praveenjha527 ,

    I’ve been going through the project description and reading more about MCP-based agent tooling to better understand the existing architecture and workflow expectations.

    What I find particularly interesting about this project is the focus on safe, policy-bound agent execution rather than only exposing generic AI tools. The emphasis on delegation scope validation, structured error handling, and pre-flight policy evaluation makes this feel like a very practical systems engineering problem with strong real-world constraints.

    I’m especially interested in contributing around:

    • MCP tool implementation and workflow design
    • backend API integration and schema handling
    • agent-tool interaction patterns
    • testing and validation workflows
    • structured error handling and observability

    My background includes working on backend AI workflows, LLM/RAG systems, APIs, and full-stack applications, so this project strongly aligns with my interests and experience.

    I’m currently continuing to explore MCP concepts and the existing UNITS workflow to better understand the implementation patterns and contribution flow. Looking forward to contributing and learning more from the team.

  18. srishtiagarwall commented on May 7, 2026

    @srishtiagarwall

    Hi @vineet-finternet @praveenjha527, I've been doing a docs-based audit using the public finternet-io/specs repo. A few specific observations before I structure my Workstream 1 plan:

    There are no events-interfaces.yaml or equivalent in the public spec. subscribe_lifecycle_events (Workstream 2) appears to have no corresponding public API surface yet. Is this intentional, or will a webhook/SSE spec be published separately?

    The recent commit to token-interfaces.yaml ("remove Proof API endpoints from public spec") likely affects check_transfer_eligibility implementation. Are the policy evaluation endpoints available in the private MCP server codebase, or should the pre-flight check compose from other endpoints?

    token-class-config-interfaces.yaml was added last week; should initiate_transfer's token class scope validation reference this spec?

    Happy to begin the Workstream 1 audit table against these 8 YAML files once I have access to the private MCP server repo.

  19. ananyaa0518 commented on May 11, 2026

    @ananyaa0518

    Hi @vineet-finternet and @praveenjha527,

    While studying the workflow design, I had a few implementation-focused questions:

    • For check_transfer_eligibility, should the response schema also include machine-actionable recovery hints for agents (example: retry window, exceeded constraint type, suggested safe amount), or should recovery reasoning remain entirely client-side?

    • For delegation validation, is scope enforcement expected only at execution time inside UNITS, or should the MCP layer maintain a lightweight pre-validation cache to reduce unnecessary policy-evaluation round trips for agents?

    • For subscribe_lifecycle_events, is the intended direction closer to webhook delivery, SSE streams, or MCP-native event propagation?

    • Are there plans for standardized observability/tracing around multi-step agent workflows (tool call chain, policy evaluation trace, delegation resolution path), or should contributors propose that structure during implementation?

    I’m currently experimenting with a small local prototype around delegation-aware agent recovery flows and wanted to align early with the intended architecture direction.

  20. aayushprsingh commented on May 12, 2026

    @aayushprsingh

    Hi @vineet-finternet @praveenjha527,

    I’m Aayush. I’m interested in this project because it sits at the intersection of backend APIs, AI agents, tool safety, and real-world financial constraints.

    Since the current MCP server repo is not public yet, I built a small public proof-of-direction repo based on the issue description:

    https://github.com/aayushprsingh/finternet-mcp-delegation-demo

    What it demonstrates:

    • get_delegation_scope
    • check_transfer_eligibility
    • get_account_summary
    • centralized delegation validation
    • structured SCOPE_EXCEEDED errors
    • no raw credential/private-key exposure
    • dry-run transfer eligibility with commitPerformed: false
    • audit metadata per tool call
    • tests for allowed and denied paths

    Verification:

    node --test
    node src/demo.js

    I also added a small docs-based audit note here:
    https://github.com/aayushprsingh/finternet-mcp-delegation-demo/blob/master/docs/audit-notes.md

    Architecture question: once contributors get access to the actual UNITS API/server surface, should the MCP layer maintain a lightweight delegation pre-validation cache to reduce repeated policy calls, or should every check_transfer_eligibility call go directly to UNITS for maximum auditability and freshness?

  21. ananyaa0518 commented on May 14, 2026

    @ananyaa0518

    Hi @vineet-finternet and @praveenjha527,

    I’ve submitted my proposal for Issue #749.

    Alongside the proposal, I built a small delegation-aware MCP prototype focused on:

    • get_delegation_scope
    • check_transfer_eligibility
    • recovery-aware structured errors
    • autonomous retry workflows
    • audit logging + observability simulation

    Demo / architecture repo:
    delegation-aware-mcp

    The current prototype explores policy-bound autonomous execution and recovery-aware agent behavior using a mock UNITS environment while aligning with the delegation safety constraints described in the issue.

    Looking forward to contributing further.

  22. Nischal1425 commented on May 16, 2026

    @Nischal1425

    Hi @vineet-finternet and @praveenjha527,

    I've been working directly with MCP server internals recently — I have a contribution to sktime-mcp (parameter validation for tool dispatch) and understand the gap between MCP's tool schema definitions and what real API surfaces actually expose. That's exactly Workstream 1.

    A few specific observations from reading the public finternet-io/specs repo:

    • subscribe_lifecycle_events has no corresponding spec file (no events-interfaces.yaml), I'd document this as an intentional deferral or propose a webhook/SSE interface to cover it
    • The recent removal of Proof API endpoints from token-interfaces.yaml likely means check_transfer_eligibility's pre-flight logic needs to compose from remaining token endpoints rather than call a policy endpoint directly
    • token-class-config-interfaces.yaml (added last week) should drive the token class scope validation in initiate_transfer

    For language: I'd propose Python with the MCP SDK if the private server is Python-based, TypeScript otherwise, happy to align with the existing codebase rather than introduce a new stack.

    My proposal will cover the full audit table (endpoint → covered/not-covered/intentionally-excluded) and the delegation-scoped tool implementations. I'll be active on this thread.

  23. Aamodx6 commented on Jun 12, 2026

    @Aamodx6

    UNITS MCP Server — Agentic Tooling and Gap Remediation: Implementation Proposal

    1. Project Understanding & Approach

    This project splits into two parallel-but-sequenced workstreams: (1) hardening the existing UNITS MCP server through systematic audit and remediation, and (2) building five new delegation-scoped agentic tools on top of that hardened foundation. The mid-point milestone requires three of the five new tools — get_account_summary, check_transfer_eligibility, and get_delegation_scope — to be fully implemented and tested. This sequencing is deliberate: these are the read-only / dry-run tools with no state-mutation risk, so they let us validate the credential-chain and scope-enforcement plumbing before building initiate_transfer and present_credential_vp, which actually move tokens or present credentials.

    2. Tech Stack Decision

    Proposed: TypeScript, using the official MCP SDK (@modelcontextprotocol/sdk)

    Rationale:

    • If the existing UNITS MCP server is already TypeScript/Node-based, this avoids a rewrite and keeps the codebase unified. I will confirm this against the actual repository in week one and pivot to Python if the existing server is Python-based, since the ticket explicitly requires selecting based on the existing codebase language.
    • TypeScript allows JSON Schema to be generated directly from Zod schemas, which satisfies the requirement for full JSON Schema input/output specs on every tool, with compile-time type safety as a bonus.
    • The MCP Inspector tool (required for integration testing) has the most mature support for TypeScript-based servers.
    • The asynchronous, event-driven model of Node.js maps naturally onto subscribe_lifecycle_events, which needs to maintain long-lived subscriptions and push events as they occur.

    If the audit shows the existing server is actually in Python or Rust, I will restate this section with equivalent reasoning (Pydantic for Python, serde + schemars for Rust); the overall architecture in this proposal does not depend on the specific language.

    3. Workstream 1 — Audit & Remediation Plan

    3.1 Audit Methodology

    1. API surface enumeration — Compile a master checklist of every UNITS App API endpoint, grouped by domain: account/token holdings, delegation management, transfer operations, credential store, dependency pointers, and lifecycle/event streams. This will be built from the UNITS OpenAPI spec if one exists, or from the route definitions in the UNITS codebase if not.
    2. Existing MCP server inventory — For every tool currently exposed by the existing MCP server, document: input schema, output schema, error handling behavior, and the underlying UNITS API endpoint(s) it wraps.
    3. Gap matrix — Cross-reference the two lists into a single table: one row per UNITS API capability, with columns for whether it is currently covered, which tool covers it (if any), and a gap classification if not.

    3.2 Gap Classification & Disposition

    Every identified gap will be resolved into exactly one of the three outputs required by the ticket:

    • New MCP tool implementation — for capabilities that are safe and useful to expose to agents (for example, a missing "list token classes" or "get transaction history" endpoint).
    • Documented limitation with rationale — for capabilities that should not be exposed to agents at all. Likely candidates based on the security framing in the ticket: raw credential issuance/revocation endpoints, account key rotation, admin-level delegation grants (an agent should never be able to grant itself broader delegation than it currently holds), and any endpoint returning raw private key material or unredacted credential claims.
    • Fix to an existing tool — for tools that exist but are defective. Each existing tool will be checked against:
      • Schema correctness — does the declared JSON Schema match actual runtime input/output?
      • Error handling — does it throw raw exceptions, or return the structured error format?
      • Response formatting consistency — are token amounts, addresses, and timestamps formatted consistently across all tools?

    3.3 Deliverable for Workstream 1

    A written audit report (markdown, committed to the repository) containing the full gap matrix, the disposition decided for each gap, and a prioritized remediation backlog — along with the actual fixes/new tools that fall within this contribution window's scope.

    4. Workstream 2 — Delegation-Scoped Agentic Tools

    4.1 Shared Architecture Components

    Before building any individual tool, four shared components need to exist, since all five tools depend on them.

    a) Delegation Credential Chain Validator

    A middleware layer, run on every tool call before any business logic executes, that:

    • Extracts the delegation credential chain from the MCP request context
    • Validates the chain's signature and expiry against the UNITS credential store
    • Resolves the chain into a delegation scope object describing: permitted token classes, per-token-class amount limits, frequency limits and the current window, expiry, the delegator's address, and the agent's address

    b) Structured Error Schema

    A single error shape used by every tool: a code field drawn from a defined enum (including SCOPE_EXCEEDED, CREDENTIAL_EXPIRED, CREDENTIAL_INVALID, TRANSFER_POLICY_FAILED, DEPENDENCY_POINTER_UNRESOLVED, ACCOUNT_NOT_FOUND, RATE_LIMIT_EXCEEDED, and INTERNAL_ERROR), a human-readable message, and a detail object for context. Every tool's error handling maps internal exceptions onto this schema — bringing existing tools in line with this schema is also part of Workstream 1's remediation if they don't follow it already.

    c) Audit Logging Middleware

    Every tool invocation writes a log entry containing: timestamp, the agent's Finternet account address (resolved from the delegation scope), the tool name, the input parameters (with any credential material redacted), and the result status. This directly satisfies the requirement that all tool calls be logged with the agent's account address.

    d) Credential Redaction Layer

    A response-serialization wrapper applied to every outgoing response that strips or replaces any field matching known credential or private-key shapes with a non-sensitive reference. This is the enforcement point for the constraint that no MCP tool may expose a raw private key or credential claim value to the agent.

    4.2 Tool-by-Tool Design

    Tool 1: get_account_summary (Mid-point deliverable)

    • Input: No parameters required — the account is resolved entirely from the delegation credential chain.
    • Output: The account's address; native token holdings by token class; proxy token holdings (with what they are a proxy of); a list of active delegations with their scope, amount limits, and expiry; and a credential store summary listing each credential's type, status (valid, expired, or revoked), and expiry — explicitly never including raw claim values.
    • Implementation steps:
      1. Resolve the delegation scope via the shared validator.
      2. Query UNITS for native holdings, proxy holdings, and active delegations, filtering results to what is visible within the requesting agent's scope. Whether an agent delegated for one token class should see holdings in other token classes is a UNITS visibility-rule question I'll confirm during week one and document the decision either way.
      3. Query the credential store and map each entry to a summary object (status and expiry only) via the redaction layer.
      4. Assemble and return the combined summary.

    Tool 2: check_transfer_eligibility (Mid-point deliverable)

    • Input: Token class, amount, recipient address, and optionally a specific set of dependency pointers to evaluate against.
    • Output: An overall eligibility boolean; a list of dependency pointers with their pass/fail/unresolved status; a list of credentials checked with their satisfied/missing/expired status; and a reason string if ineligible.
    • Implementation steps:
      1. Resolve the delegation scope and immediately check the requested amount against the scope's amount and frequency limits for that token class. If this fails, short-circuit with a SCOPE_EXCEEDED error without calling UNITS at all — a cheap early rejection.
      2. Call UNITS' transfer policy evaluation in dry-run mode. Whether UNITS exposes a native dry-run endpoint, or whether this tool needs to construct the evaluation itself by reading the transfer policy and dependency pointer graph for the token class, needs confirming during the audit.
      3. Report pass/fail/unresolved status for each dependency pointer in the policy.
      4. Report satisfied/missing/expired status for each credential requirement, without exposing values.
      5. Aggregate everything into the overall eligibility boolean.

    Tool 3: get_delegation_scope (Mid-point deliverable)

    • Input: No parameters — resolved from the credential chain, as with Tool 1.
    • Output: The delegation ID, delegator and agent addresses, permitted token classes, amount limits, frequency limits (including the current count in the active window), expiry, and the remaining capacity per token class for the current window.
    • Implementation steps:
      1. This tool is largely a direct projection of the delegation scope object produced by the shared credential chain validator — most of the engineering effort here actually goes into making that validator correct and complete.
      2. Add the current-window usage count and remaining capacity by querying UNITS' usage tracking for the delegation.
      3. Because this tool is intentionally a simple "self-check," the implementation here will stay thin, with effort concentrated on the shared validator instead.

    Tool 4: initiate_transfer (post-mid-point)

    • Input: Token class, amount, recipient address, and an optional memo.
    • Output: The pre-flight eligibility result (same shape as check_transfer_eligibility's output), a committed boolean, a transfer ID if committed, and a structured error if not.
    • Implementation steps:
      1. Internally invoke the same eligibility-checking logic used by check_transfer_eligibility before any commit path runs. The commit function takes this result as an internal argument rather than something the agent can supply, which is what guarantees agents cannot skip the pre-flight check.
      2. If the result is ineligible, return immediately with committed: false and the pre-flight result — no transfer is sent to UNITS.
      3. If eligible, submit the transfer to UNITS and receive a transfer ID.
      4. Log the full operation — pre-flight result, commit decision, and outcome — via the audit middleware.
      5. Return both the pre-flight result and the commit outcome together. This combined-response shape is a design decision I'd like the mentor to confirm before implementation, since it affects how agent harnesses parse the response.

    Tool 5: present_credential_vp (post-mid-point)

    • Input: The credential type required by a transfer policy, and a reference to the transfer or policy requirement it is being presented to satisfy.
    • Output: A confirmation that a Verifiable Presentation was constructed and submitted, the resulting VP reference ID, and whether the presentation satisfied the policy requirement — never the underlying credential claim values.
    • Implementation steps:
      1. Look up the relevant credential in the account's credential store via the shared validator/redaction layer, without ever surfacing its raw claims to the agent.
      2. Construct a Verifiable Presentation server-side from that credential, scoped to only the claims the policy requirement actually needs.
      3. Submit the VP to UNITS against the relevant transfer policy requirement.
      4. Return the VP reference ID and the satisfaction result to the agent.
      5. Log the presentation event via the audit middleware, including which credential type was used (but not its contents).

    5. Testing Strategy

    Three levels of testing, as required by the ticket:

    1. Unit tests per tool — each tool tested in isolation against a mocked UNITS server, covering: happy path, scope-exceeded rejections, expired/invalid credential handling, and malformed input rejection against the JSON Schema.
    2. Integration tests — full request-response cycles run against a local Docker Compose UNITS development instance, using the MCP Inspector tool to drive each tool call and verify schema conformance end-to-end.
    3. End-to-end agentic workflow tests — at least two complete delegation-scoped workflows exercised through a real AI agent client (Claude via the Anthropic API with tool use). Proposed workflows:
      • Workflow A (read-only): Agent calls get_delegation_scope, then get_account_summary, then check_transfer_eligibility for a hypothetical transfer, and reports a summary to the user — exercises all three mid-point tools together.
      • Workflow B (transfer): Agent checks eligibility, presents a required credential via present_credential_vp, then calls initiate_transfer, and confirms the result — exercises the full post-mid-point flow including the credential presentation step.

    6. Proposed Timeline

    Phase Work Output
    Week 1 Confirm tech stack against existing codebase; complete API surface enumeration and existing-tool inventory Gap matrix draft
    Week 2 Finalize gap classification and dispositions; begin remediation fixes; build shared architecture components (validator, error schema, audit logging, redaction layer) Audit report; shared components
    Week 3 Implement get_delegation_scope and get_account_summary Two tools + unit tests
    Week 4 Implement check_transfer_eligibility; integration tests for all three mid-point tools Mid-point milestone: three tools implemented and tested
    Week 5 Implement initiate_transfer Tool + unit tests
    Week 6 Implement present_credential_vp Tool + unit tests
    Week 7 Integration tests for remaining tools; build end-to-end agent test harness Workflow A and B passing
    Week 8 Final remediation items from Workstream 1; documentation; buffer for review feedback Final submission

    7. Open Questions for Mentor(@vineet-finternet )

    • Confirm the language/runtime of the existing UNITS MCP server so the tech stack decision in Section 2 can be finalized.
    • Confirm whether UNITS exposes a native dry-run policy evaluation endpoint, or whether check_transfer_eligibility needs to construct this from the policy and dependency pointer graph directly.
    • Confirm cross-token-class visibility rules for get_account_summary when an agent's delegation is scoped to a subset of token classes.
    • Feedback on the combined pre-flight + commit response shape proposed for initiate_transfer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy