Skip to main content
Glama
README.md
# maltego-mcp

Model Context Protocol (MCP) server for Maltego v4.13.0 graphs (`.mtgx` / GraphML), entity schemas, local and remote (TDS v2 / TRX v3) transforms, native OSINT transforms, `.machine` scripts, and Maltego Desktop CLI / `AutomationServer` IPC.

## Requirements

- Node.js v24+ (`v24.21.0` tested) and npm 12+
- Optional: Maltego Desktop v4.13.0 (`/usr/bin/maltego` and `~/.maltego/v4.13.0`) for environment inspection, local/cached discovery, `.machine` inspection, and `--automationPort` GraphML push
- Optional: Python 3 (`python3`) if executing Python local transforms

## Installation & Build

```bash
git clone https://github.com/Steph-ux/maltego-mcp.git
cd maltego-mcp
npm install
npm run build
```

Run the full test suite (compiles TypeScript and executes all `test/*.test.mjs` suites):

```bash
npm test
```

## Transport & CLI Options

By default, `maltego-mcp` starts on `stdio` JSON-RPC (all server logs go to `stderr` so `stdout` stays clean for MCP framing).

```bash
# stdio transport (default)
node dist/index.js
node dist/index.js --stdio

# Streamable HTTP transport (/mcp and /health)
node dist/index.js --http
node dist/index.js --http 3000 --host 127.0.0.1 --token my-secret-token
node dist/index.js --http --port 3000 --token my-secret-token
```

Flags:

- `--stdio` - Use stdio MCP transport (default)
- `--http [port]` - Use Streamable HTTP MCP transport (`/mcp` and `/health`)
- `--host <addr>` - HTTP bind address (default `127.0.0.1`, or `MCP_HTTP_HOST`)
- `--port <port>` - HTTP listen port (default `3000`, or `MCP_HTTP_PORT`)
- `--token <secret>` - Require `Authorization: Bearer <secret>` on `/mcp`
- `-h`, `--help` - Show CLI usage

Tool outputs are automatically bounded to `<= 4 MiB` (`4194304` bytes) for safe MCP transport framing.

## Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
| `MALTEGO_BIN` | `/usr/bin/maltego` | Path to the Maltego launcher binary |
| `MALTEGO_HOME` | `~/.maltego/v4.13.0` | Path to the Maltego user configuration directory |
| `MALTEGO_WORKSPACE_DIR` | Current working directory | Base directory confining relative/workspace `.mtgx`, `.entity`, `.machine`, and transform outputs |
| `MALTEGO_PYTHON_BIN` | `python3` | Python interpreter used by generated Python local transform templates |
| `MALTEGO_TRANSFORM_TIMEOUT_MS` | `30000` | Default timeout (ms) for local and remote transforms |
| `MALTEGO_MAX_GRAPH_BYTES` | `33554432` (32 MiB) | Maximum uncompressed GraphML / `.mtgx` graph size |
| `MALTEGO_ALLOW_EXTERNAL_TRANSFORMS` | `false` | Set `"true"` to allow remote TDS/TRX, external DNS, RDAP/WHOIS, or HTTP/TLS fetches against non-localhost targets |
| `MCP_TRANSPORT` | `stdio` | Default transport (`stdio` or `http`) |
| `MCP_HTTP_HOST` | `127.0.0.1` | Default HTTP bind host |
| `MCP_HTTP_PORT` | `3000` | Default HTTP listen port |
| `MCP_HTTP_TOKEN` | `""` | Default Bearer token required for Streamable HTTP `/mcp` requests |

## Registered Tools (31)

### `.mtgx` / GraphML Archive Tools (8)

- `mtgx_inspect` - Inspect a `.mtgx` archive: returns metadata, entity/link type counts, and paginated entities and links (cleanly detects `.mtgl` Pandora/Lucene archives with a structured error).
- `mtgx_create` - Atomically create a new Maltego v4.13.0 `.mtgx` archive from entities, directed links, and metadata.
- `mtgx_add_entities` - Add entities to an existing `.mtgx` archive with auto-generated IDs, grid placement, and optional deduplication.
- `mtgx_add_links` - Add directed links between existing entities in a `.mtgx` archive.
- `mtgx_query_graph` - Query entities and induced links by type, value substring, property match, bookmark, or k-hop BFS neighborhood.
- `mtgx_update_entity` - Update an entity's value, properties, notes, bookmark, position, or weight in a `.mtgx` archive.
- `mtgx_remove_entities` - Remove entities by ID from a `.mtgx` archive and cascade-delete incident links.
- `mtgx_export_graphml` - Export a `.mtgx` archive as standalone GraphML XML or JSON (optionally writing atomically to a file).

### Entity Schema & Builder Tools (5)

- `entity_list_types` - List built-in Maltego v4.13.0 entity types and optionally scan custom/local plain-XML `.entity` directories (skipping binary/encrypted files safely).
- `entity_get_schema` - Return the full property schema, inheritance chain, primary property, and JSON/XML examples for an entity type.
- `entity_build` - Validate an entity's type, primary value, and typed fields and emit canonical JSON plus optional Transform `<Entity>` XML and GraphML `<mtg:MaltegoEntity>` XML.
- `entity_parse_xml` - Parse Transform `<Entity>` / `<MaltegoMessage>`, GraphML `<mtg:MaltegoEntity>` / `<node>`, or `.entity` `<MaltegoEntity>` definition XML into normalized JSON.
- `entity_create_definition` - Build a custom `.entity` XML definition and optionally write it safely within `MALTEGO_WORKSPACE_DIR`.

### Local & Remote (TDS/TRX) Transform Tools (7)

- `transform_run_local` - Execute a local Maltego transform binary/script (`shell: false`) using Maltego's CLI field escaping protocol and parse its XML response or exception message (supports optional `output_mtgx` merge).
- `transform_list_local` - Discover local, cached remote, custom transforms, transform sets, and server entries without reading secrets or activation files.
- `transform_discover_tds` - Query TDS v2 XML (`_TRANSFORMS`, `_CONFIG`, `_PERFORMANCE`) or TRX v3 JSON (`/transforms`, `/assets/*`) discovery endpoints.
- `transform_run_tds` - Execute a remote transform via TDS v2 XML or TRX v3 JSON (external hosts gated by `MALTEGO_ALLOW_EXTERNAL_TRANSFORMS=true`; supports optional `output_mtgx` merge).
- `transform_build_request` - Build a TDS v2 `<MaltegoTransformRequestMessage>` XML or TRX v3 JSON request payload offline.
- `transform_parse_response` - Parse a TDS v2 XML or TRX v3 JSON transform response into normalized entities, UI messages, buttons, and exceptions.
- `transform_create_local_template` - Generate an executable Python 3 or Node.js local transform script plus a matching `.transform` XML descriptor.

### Built-in OSINT Transform Tools (5)

All 5 OSINT tools support optional `output_mtgx` to write or merge discovered entities and links directly into a `.mtgx` archive.

- `osint_domain_to_dns` - Resolve A, AAAA, MX, NS, TXT, and CNAME records plus SPF/DMARC policies into normalized Maltego entities, links, GraphML, and Transform XML.
- `osint_ip_analyze` - Classify IPv4/IPv6 addresses (RFC1918, loopback, link-local, CGNAT, multicast, ULA, public) with optional PTR reverse DNS and RDAP/WHOIS enrichment.
- `osint_website_and_tls` - Fetch an HTTP(S) page and inspect its TLS certificate, extracting status, title, tech hints, links, hosts, emails, and TLS SANs/Issuer/Subject.
- `osint_extract_entities` - Extract deduplicated EmailAddress, Domain, IPv4Address, URL, Hash, and PhoneNumber entities from raw text or a workspace file.
- `osint_run_pipeline` - Run a bounded, cycle-free multi-step OSINT pipeline chaining `extract`, `dns`, `ip_analyze`, and `website_tls`.

### Desktop, CLI, Machines & Automation IPC Tools (6)

- `maltego_environment_info` - Inspect Maltego binary, clusters, Java 11 JVM info, non-secret userdir counts, and redacted `messages.log` tail (strictly excludes `MaltegoID.*` and `Certificates/`).
- `maltego_list_servers_and_machines` - List `.tas` servers (credentials redacted), `.seed`/`.hub` files, `TransformSets`, and `.machine` scripts, or inspect a specific `.machine` script.
- `maltego_parse_machine` - Parse and validate a `.machine` DSL script, extracting metadata, blocks, and transform invocations.
- `maltego_create_machine` - Validate, format, and optionally write a `.machine` DSL script safely within `MALTEGO_WORKSPACE_DIR`.
- `maltego_automation_push` - Push a validated `<graphml>` payload over TCP to Maltego Desktop's `--automationPort` (`AutomationServer`) to merge into the active UI graph.
- `maltego_cli_launch` - Build and optionally execute a validated shell-free invocation of `/usr/bin/maltego` (defaults to `dry_run: true`).

## Security Notes

- The built-in XML parser (`src/utils/xml.ts`) rejects all `<!DOCTYPE`, `<!ENTITY`, and DTD declarations to prevent XXE and billion-laughs attacks, and enforces size, depth, and node limits.
- Archive utilities (`src/utils/zip.ts`) reject zip-slip path traversal and bound uncompressed entry and archive sizes.
- Path inputs are validated through `assertSafePath`, local process execution uses `spawn(..., { shell: false })`, and non-local network calls in OSINT and TDS/TRX tools are disabled unless `MALTEGO_ALLOW_EXTERNAL_TRANSFORMS=true`.
- Sensitive Maltego identity/key files (`MaltegoID.activation`, `MaltegoID.keypair`, `Certificates/`, and `.tas` credentials) are excluded or redacted.

TDQS

B3.4/5.0

Scored across 31 tools

Disambiguation4/5

Tools are grouped by domain and mostly target distinct operations across .mtgx archives, entity schemas, transforms, machines, and OSINT. A few clusters are close, such as entity_build vs. entity_create_definition and mtgx_inspect vs. mtgx_query_graph, but their descriptions make the boundaries workable.

Naming Consistency4/5

Names consistently use snake_case with semantic prefixes for domain grouping (mtgx_, entity_, transform_, osint_, maltego_). Most names follow prefix_action_object patterns, though a few like osint_domain_to_dns and maltego_automation_push are less verb-first.

Tool Count3/5

Thirty-one tools is heavy for a single MCP server, but the breadth of the Maltego integration means the tools are split across several coherent subdomains. The count is on the high side and could overwhelm selection, but most tools do appear to earn their place.

Completeness4/5

The surface covers graph archive creation/inspection/editing, entity schema/build/parse, local and TDS transform workflows, machine scripting, automation push, and OSINT transforms. Minor gaps remain, such as standalone link removal/update and archive deletion lifecycle operations.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues