Skip to content

Add sign parameter to upload_data for notary-signed uploads #44

Description

@crtahlin

Summary

The gateway supports a sign query parameter on POST /api/v1/data/. When sign=notary, the gateway cryptographically signs the uploaded data using its notary service, providing provenance guarantees at upload time. This is the simplest way to add provenance to data — no blockchain interaction required.

What to Implement

1. Gateway Client (gateway_client.py)

Add sign parameter to upload_data():

def upload_data(self, data: str, stamp_id: str, content_type: str = "application/json", sign: Optional[str] = None) -> Dict[str, Any]:

When sign is provided, include it as a query parameter:

params = {
    'stamp_id': stamp_id,
    'content_type': content_type
}
if sign:
    params['sign'] = sign

2. MCP Server (server.py)

Add sign to the upload_data tool schema:

"sign": {
    "type": "string",
    "description": "Signing method for provenance. Use 'notary' to have the gateway cryptographically sign the data, creating a verifiable proof of upload. Leave empty for unsigned upload.",
    "enum": ["notary"]
}

Pass through in the handler:

sign = arguments.get("sign")
result = gateway_client.upload_data(data, clean_stamp_id, content_type, sign=sign)

When sign=notary was used, include signing info in the success response.

3. Response Enhancement

When notary signing is used, the gateway response may include additional fields. Surface these in the upload response:

  • Notary signature info
  • Signer address

Files to Modify

  • swarm_provenance_mcp/gateway_client.py — add sign param to upload_data()
  • swarm_provenance_mcp/server.py — add sign to tool schema and handler
  • tests/test_gateway_client.py — add tests for signed uploads
  • tests/test_integration.py — add integration tests

Reference

  • Gateway endpoint: POST /api/v1/data/?sign=notary
  • Related: notary_info tool (check if notary is available before signing)
  • Follow existing pattern: see how content_type optional param is handled in upload_data

Acceptance Criteria

  • upload_data tool accepts optional sign parameter
  • When sign="notary", request includes ?sign=notary query param
  • Tool description explains what notary signing does
  • Success response shows signing info when notary was used
  • Works with existing stamp validation flow
  • Tests cover signed and unsigned upload paths

Activity

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

    enhancementNew feature or requestgateway-syncSync with swarm_connect gateway changespriority-highHigh priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions