Skip to content

About

Spike: export an AWS Context graph to JSON, Taxi, OWL and Markdown. Take the map AWS builds of your data, and keep it.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

aws-context-export

Take the map AWS Context builds of your data, and keep it.

This is a spike. We built it at Orbital to test AWS Context the week it launched, and we're sharing it as it stands. It works on the graphs we tried and its tests pass, but it isn't a supported Orbital product: expect rough edges, and expect it to change. Issues and pull requests are welcome.

AWS Context reads your AWS catalogue and builds a graph of what your data means: the tables and columns, how they join, the business terms, and what your curators approved. It's free to build, and it's good. But AWS offers no way to export it, so the map only works inside AWS.

context-export reads the graph back out through Context's own read calls, and writes it in formats you own:

flowchart LR
  C["AWS Context graph"] -->|read-only crawl| E["context-export"]
  E --> J["snapshot.json"]
  E --> T["Taxi packages"]
  E --> O["OWL (Turtle)"]
  E --> M["Data dictionary"]
  T --> R["Orbital: query and write across AWS and everything else"]
  T --> H["TaxiHub: publish and share"]
  O --> B["Back into Context, or any OWL tool"]
Loading
  • Keep a copy and see how it changes between exports.
  • Review it as a document, not through an agent.
  • Use it outside AWS. In Orbital, the Taxi output answers one question across the sources Context mapped and the ones it can't reach (other databases, APIs, other clouds), and can write back, checking who is asking.

It never writes to AWS, and every run tells you what it reached and what it may have missed.

Quick start

Python 3.11 or later.

pipx install git+https://github.com/orbitalapi/aws-context-export
context-export --profile my-profile --region eu-west-1 --format json,taxi,owl,md --out out/my-context

That exports the only agent context in the region, within a budget of 50 agent units (about $2; see Costs). Then open out/my-context/coverage.md and out/my-context/data-dictionary.md.

No AWS account handy? Replay the example graph that ships with the tests:

git clone https://github.com/orbitalapi/aws-context-export && cd aws-context-export
python3 -m venv .venv && . .venv/bin/activate && pip install .
context-export --replay tests/fixtures/api/context-calls.jsonl --format json,taxi,owl,md --out out/example

What you get

File What's in it
snapshot.json Every node and edge the crawl reached, source metadata, curation decisions and coverage, versioned. Re-generate any format from it later with no AWS calls.
taxi/<name>-ontology/ A Taxi package: one semantic type per column and term, one model per table, each carrying its Context node id and whether a person approved it. Pure Taxi, ready for TaxiHub.
taxi/<name>-bindings/ Orbital bindings for the sources behind the graph (S3, DynamoDB, JDBC where Context knows one).
<name>.ttl OWL classes and properties, written to the rules AWS gives for uploading an ontology to Context.
data-dictionary.md A readable data dictionary: column types, definitions, joins, curation decisions.
coverage.md What the crawl reached, which reads failed, and where there may be gaps.

Here's a table from the example graph as Taxi (node ids trimmed):

[[ The account's name: the company, or the person for an individual.
Columns: example-crm-accounts.account_name. ]]
@context.Node(nodeId = "…", nodeType = "AWS::CONTEXT::COLUMN", name = "account_name", curation = "approved")
type ExampleCrmAccountName inherits String

[[ Columns: example-crm-accounts.account_id. ]]
@context.Node(nodeId = "…", nodeType = "AWS::CONTEXT::COLUMN", name = "account_id", curation = "generated")
@context.Draft
type ExampleCrmAccountId inherits Decimal

@context.Node(nodeId = "…", nodeType = "AWS::CONTEXT::TABLE", name = "example-crm-accounts", curation = "generated")
model ExampleCrmAccount {
   account_id : ExampleCrmAccountId
   account_name : ExampleCrmAccountName?
   country : ExampleCrmAccountCountry?
   owner_rep_id : ExampleCrmSalesRepId?
}

@context.Draft marks what no curator has approved in Context yet, so you can see at a glance what's been reviewed.

Run it with Orbital

The ontology package is plain Taxi: publish it to TaxiHub, or add it to an Orbital workspace. Then add the bindings package and define one connection in Orbital (named by --connection-name, default aws) that can read the bucket and the tables. Orbital can then answer one question across the AWS sources Context mapped and the systems it can't reach, with lineage for every value. With --writable TABLE, it can also write back, governed by who is asking.

Permissions

The exporter never writes to AWS. It writes its cache and exports locally. Even --writable only generates Taxi declarations for use in a separate Orbital deployment.

The following identity policy covers the calls a full crawl makes. Replace the example region, account, agent context, mapped custom ontology, Glue database and DynamoDB table with your own values. List each resource you want to include. Context discovery lists contexts in the selected region.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DiscoverContexts",
      "Effect": "Allow",
      "Action": "context:ListAgentContexts",
      "Resource": "*",
      "Condition": {"StringEquals": {"aws:RequestedRegion": "eu-west-1"}}
    },
    {
      "Sid": "ReadGraphAndCuration",
      "Effect": "Allow",
      "Action": [
        "context:GetAgentContext",
        "context:SearchAgentContext",
        "context:TraverseAgentContext",
        "context:ListCurationProposals",
        "context:ListChangeSets",
        "context:ListChangeSetOperations"
      ],
      "Resource": "arn:aws:context:eu-west-1:111122223333:agent-context/ac-deadbeefdeadbeefdeadbeeffeed0001"
    },
    {
      "Sid": "ReadMappedCustomOntology",
      "Effect": "Allow",
      "Action": "context:GetOntology",
      "Resource": "arn:aws:context:eu-west-1:111122223333:ontology/ont-deadbeefdeadbeefdeadbeeffeed0001"
    },
    {
      "Sid": "ReadGlueTableMetadata",
      "Effect": "Allow",
      "Action": "glue:GetTables",
      "Resource": [
        "arn:aws:glue:eu-west-1:111122223333:catalog",
        "arn:aws:glue:eu-west-1:111122223333:database/example_payments",
        "arn:aws:glue:eu-west-1:111122223333:table/example_payments/*"
      ]
    },
    {
      "Sid": "ReadDynamoDBTableMetadata",
      "Effect": "Allow",
      "Action": "dynamodb:DescribeTable",
      "Resource": "arn:aws:dynamodb:eu-west-1:111122223333:table/example-crm-accounts"
    }
  ]
}

GetOntology is needed only to discover types from a mapped custom ontology with the default --seed-types all. System ontology definitions ship with the exporter. With --no-sources, omit both the Glue and DynamoDB statements. Snapshot regeneration and fixture replay require no AWS permissions.

The MCP proxy runs with --read-only and uses the same per-operation IAM actions. AWS also checks endpoint access through context-mcp:InvokeMcp, which it allows by default. AWS Context MCP authentication

Use

# Everything, from the only agent context in the region, within a budget of 50 agent units (about $2):
context-export --profile my-profile --region eu-west-1 --format json,taxi,owl,md

# Choose the context, name the outputs, and redact account ids before sharing:
context-export --agent-context sales-context --format json,taxi,owl,md \
  --taxi-org com.acme --taxi-name acme-context --strip-prefix prod- \
  --owl-namespace 'https://acme.example/ontology/sales#' --redact --out out/sales

# Through Context's MCP server instead of the signed API (same results):
context-export --transport mcp --agent-context sales-context

# Re-generate formats from a snapshot, with no AWS calls at all:
context-export --from-snapshot out/sales/snapshot.json --format taxi,owl

Crawl and output options

Option What it does
--max-units N Stops before the crawl's estimated agent units pass N (default 50).
--cache FILE Every call is cached. Run again with the same cache to resume a stopped crawl: repeated calls are free. --refresh starts a fresh cache.
--seed-types Which node types to seed from: all (default), none, or a list such as AWS::CONTEXT::TABLE.
--seed-query Q Adds a search to seed from (repeatable).
--max-nodes N Bounds the walk.
--no-changelog Don't add nodes that only Context's change log knows. They are still counted in coverage.
--writable TABLE Adds an upsert for that table to the Taxi bindings, only where the source declares a key.
--redact Replaces account ids with AWS's placeholder 111122223333 and removes role names and emails, in every output.
--record-fixtures DIR Records calls with account IDs, roles and emails redacted. Resource names, context IDs and pagination tokens still need review before sharing.

To check the TaxiHub package locally, use Docker with orbitalhq/orbital:latest already installed, or set ORBITAL_IMAGE to a local Orbital image.

tools/taxihub_dryrun.sh out/sales/taxi

How it reads the graph

No call lists the whole graph, so the tool crawls it:

  1. Seeds. One search per node type that the context's ontologies allow (filtered on nodeType), a few broad searches, and a search for every Glue table in the databases Context knows.
  2. Walk. Breadth first. Each node's neighbours are fetched in both directions, with the edges between them, until nothing new turns up or the budget runs out.
  3. Curation record. Every curation proposal (all statuses), every change set and its operations. Replaying the published change sets gives a second view of the graph. The tool uses it to find nodes the crawl missed, and to label every node and edge: approved (a curator accepted it), edited (changed directly, with no review), generated (built by Context and never reviewed), or unknown. Changes still waiting for review, and rejected ones, are listed separately. They are not part of the graph.
  4. Sources. Glue GetTables for columns, types, partition keys, the S3 location and file format. DynamoDB DescribeTable for keys.

Costs

The exporter estimates Context reads at $0.04 per agent unit. AWS's trial figures equate 3,750 units to roughly 20,000 searches or 125,000 traversals. That gives an estimated 0.19 units per search and 0.03 per traversal. AWS does not publish a per-call rate for curation reads, so the estimate counts each as a search. Glue and DynamoDB requests are outside the Context estimate. AWS Context pricing

Graph Estimated units About
Example graph with 3 tables, 25 nodes and 13 change sets 17 $0.68
500 tables, 10,000 nodes, 2,000 change sets (projection) ~780 ~$31

Most of a small graph's cost is the fixed seeding: about 60 searches, roughly 11 units. On a big graph, traversals and change-set reads dominate. Cached calls are free, so re-running or resuming costs only what's new. Every run's coverage.md lists its live and cached calls and its estimate. --max-units caps the estimate. Actual charges depend on the work AWS meters.

Limits

Context has no export, so the coverage report says what was reached against the denominators the tool can see: Glue's tables and columns, and Context's own change log. It cannot see:

  • documents inside knowledge-base document graphs (only the nodes Context makes from them);
  • entities restricted by document ACLs to people other than the caller;
  • agent traces, and change sets older than the list calls return;
  • ontology inductions that aren't published yet;
  • how Context's agentic retrieval actually plans and runs a query;
  • for DynamoDB and other key-value tables, any attribute Context never recorded. Those sources declare only their keys, so there is no full list to check against.

The exporter requests 25 search results per page and follows pagination. A full filtered search is flagged because additional nodes can still require traversal or a more specific seed query.

Imported OWL classes reached by the crawl appear in Taxi and OWL even when no connection mapping names their ontology. OWL retains their original class IRIs. Their subClassOf edges become Taxi inheritance and OWL subclass triples. The dictionary lists grounding links, Taxi documents them on the source types and models, and OWL uses the cx:mappedTo annotation. The snapshot records each grounding once per source, target and edge kind. It also preserves graph data beyond the writers' projections, including imported property nodes.

The Taxi bindings use Orbital's connector annotations. They are deployment config for an Orbital, not a TaxiHub package. S3 data is bound only when it is CSV.

The OWL file is checked locally against AWS's documented rules and limits. Uploading it to Context creates a resource, and this tool never does that.

Tests

From the checkout, install the test extra into the environment used above.

python -m pip install -e '.[test]'
python -m pytest -q

The suite replays anonymized API and MCP recordings offline. The TaxiHub dry run also needs a local Docker daemon and Orbital image and skips when either is unavailable.

Contributing

Pull requests and bug reports are welcome. When reporting an export issue, include the exporter version and a small anonymized example that reproduces it. GitHub Issues

Licensed under the Apache License, Version 2.0.

This project is not affiliated with or endorsed by Amazon Web Services. AWS and AWS Context are trademarks of Amazon.

About

Spike: export an AWS Context graph to JSON, Taxi, OWL and Markdown. Take the map AWS builds of your data, and keep it.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages