Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
"description": "AI trading agent for Hyperliquid: Claude trades perps with an exact stop and target on every order. 30 MCP tools: desk briefs for oil and metals, bracket orders, risk sizing (3x, 1% per trade, one position by default), account reads. Mainnet by default, testnet opt-in, read-only without a key. Free: no builder fee.",
"category": "finance",
"keywords": ["hyperliquid", "trading", "perps", "mcp", "claude-code", "risk-management", "oil", "gold", "ai-agent", "trading-agent", "ai-trading"]
},
{
"name": "pathiel-research",
"source": "./services/research_mcp",
"description": "The risk-gated research layer AI agents trade through: a free, read-only, keyless MCP server with 6 tools (research_brief, events, prediction_odds, fred_series, headlines, levels) for BRENTOIL, HYPE, BTC, ETH and SP500. Hyperliquid public candles, news/RSS, Polymarket/Kalshi odds, the scheduled-event calendar, and pathiel's own stored desk thesis. Never touches a key, an account or an order.",
"category": "finance",
"keywords": ["research", "mcp", "claude-code", "hyperliquid", "polymarket", "kalshi", "fred", "market-research", "oil", "crypto"]
}
]
}
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pathiel",
"displayName": "pathiel",
"version": "0.8.0",
"version": "0.9.0",
"description": "AI trading agent for Hyperliquid: Claude trades perps with an exact stop and target on every order. 30 MCP tools: desk briefs for oil and metals, bracket orders, risk sizing (3x, 1% per trade, one position by default), account reads. Mainnet by default, testnet opt-in, read-only without a key. Free: no builder fee.",
"author": {
"name": "Julian Martinez",
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ All notable changes to pathiel. The format follows

## [Unreleased]

## [0.9.0] - 2026-11-21

### Added

- `pathiel-research`, a second plugin and MCP server in this repo: free,
read-only and keyless. Six tools (`research_brief`, `levels`, `events`,
`headlines`, `prediction_odds`, `fred_series`) for BRENTOIL, HYPE, BTC,
ETH and SP500, built from the same intel the trading desks read. Install:
`/plugin install pathiel-research@pathiel`. `fred_series` uses your own
free `FRED_API_KEY`; every other tool needs no key.

### Changed

- The privacy page describes the research server: what it reads, the local
usage count it keeps, and that it sends nothing off your machine.

### Security

- The research server cannot import order or signing code and never opens
`~/.pathiel` or `.env.local`; a gate test
(`services/research_mcp/tests/test_no_trading_imports.py`) checks both.

## [0.8.0] - 2026-11-21

### Security
Expand Down Expand Up @@ -446,6 +468,7 @@ builder fee, and listing metadata for the MCP directories. Release notes:
`/pathiel:setup`, installed from this repo. Mainnet only.

[Unreleased]: https://github.com/Julian-dev28/pathiel/compare/v0.7.2...HEAD
[0.9.0]: https://github.com/Julian-dev28/pathiel/releases/tag/v0.9.0
[0.8.0]: https://github.com/Julian-dev28/pathiel/releases/tag/v0.8.0
[0.7.2]: https://github.com/Julian-dev28/pathiel/releases/tag/v0.7.2
[0.7.1]: https://github.com/Julian-dev28/pathiel/releases/tag/v0.7.1
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![pathiel MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/Julian-dev28/pathiel/badges/score.svg)](https://glama.ai/mcp/servers/Julian-dev28/pathiel)
[![Listed on mcpservers.org](https://mcpservers.org/badge.svg)](https://mcpservers.org/servers/julian-dev28/pathiel)
[![pathiel MCP on mcprush](https://mcprush.com/badge/pathiel-mcp/score.svg)](https://mcprush.com/to/pathiel-mcp?ref=badge)
[![Version 0.8.0](https://img.shields.io/badge/version-0.8.0-informational.svg)](CHANGELOG.md)
[![Version 0.9.0](https://img.shields.io/badge/version-0.9.0-informational.svg)](CHANGELOG.md)
[![MCP server](https://img.shields.io/badge/MCP-30_tools-6f42c1.svg)](docs/overhaul/MCP.md)
[![CI](https://github.com/Julian-dev28/pathiel/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Julian-dev28/pathiel/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
Expand All @@ -32,6 +32,8 @@ Desk briefs for crude oil (Brent and WTI), metals (gold and silver), the S&P 500

pathiel never touches a position or order you placed yourself unless you say so in that call.

Research only, as its own server: `/plugin install pathiel-research@pathiel` adds `pathiel-research`, six read-only tools (a research brief, levels, the event calendar, headlines, prediction-market odds, FRED macro series) that need no account and no key and cannot place an order ([details](services/research_mcp/README.md)).

## Install in 30 seconds

In Claude Code:
Expand Down Expand Up @@ -74,7 +76,7 @@ registry as `io.github.Julian-dev28/pathiel`.

```bash
docker run -i --rm --user "$(id -u):$(id -g)" -v "$HOME/.pathiel:/data" \
ghcr.io/julian-dev28/pathiel-mcp:0.8.0
ghcr.io/julian-dev28/pathiel-mcp:0.9.0
```

To build it yourself: `docker build -f Dockerfile.mcp -t pathiel-mcp .`
Expand Down Expand Up @@ -321,6 +323,7 @@ the keys and state gone.
| [docs/BUILDER_FEE.md](docs/BUILDER_FEE.md) | the fee is waived; revoking a 0.4.0 approval; how it works if it returns |
| [docs/strategy/OIL_RULES.md](docs/strategy/OIL_RULES.md) | the rules every oil bracket must pass, and what is not known |
| [docs/overhaul/MCP.md](docs/overhaul/MCP.md) | all 30 public tools, and the operator's 60 |
| [services/research_mcp/README.md](services/research_mcp/README.md) | the research MCP: a free, read-only, keyless second plugin (`/plugin install pathiel-research@pathiel`) for levels, catalysts, headlines, prediction-market odds, FRED series and pathiel's stored desk theses; no key, no account, no order, ever |
| [docs/PRIVACY.md](docs/PRIVACY.md) | the research pool: what is public, what is not, how to join, leave and come back |
| [Scoreboard](https://julian-dev28.github.io/pathiel/scoreboard/) | the research pool's public, graded results |
| [SECURITY.md](SECURITY.md) | where keys live, what pathiel never does, how to report a problem |
Expand Down
25 changes: 25 additions & 0 deletions docs/RELEASE_NOTES_v0.9.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# pathiel 0.9.0

Released 2026-11-21. The research server ships: the full list is in
[CHANGELOG.md](../CHANGELOG.md). pathiel stays free: no builder fee.

## New: pathiel research, no key, no trading

A second plugin in the same marketplace. It reads markets and never places
an order: it cannot import order or signing code, and a gate test proves it.

| Tool | What it answers |
|---|---|
| `research_brief` | One brief per coin: levels, catalysts, headlines, odds and the desk's stored call |
| `levels` | Mid, recent ranges and ATR from Hyperliquid's public data |
| `events` | The scheduled-event calendar: FOMC, CPI, OPEC+, Congress, sanctions dates |
| `headlines` | Recent news for a coin or a topic |
| `prediction_odds` | Polymarket and Kalshi odds |
| `fred_series` | Any FRED macro series, with your own free FRED key |

Coins: Brent, HYPE, BTC, ETH, S&P 500.

Install: `/plugin marketplace add Julian-dev28/pathiel`, then
`/plugin install pathiel-research@pathiel`.

Not financial advice.
38 changes: 38 additions & 0 deletions docs/design/RESEARCH_MCP_PAID_TIER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# research MCP: the paid tier (design, not built)

v1 (`services/research_mcp`) is local stdio, free, keyless, no hosting.
This sketches v2: a hosted HTTP MCP with API-key metering, for after v1 has
proven usage.

## Shape

- **Transport**: HTTP MCP (streamable HTTP, per the current MCP spec)
behind a thin auth layer, deployed as its own service (own container, own
deploy unit; CLAUDE.md's services-first rule holds here too: it does not
become a mode flag on v1's stdio server). Same six tools, same
`tools.py` logic; only the transport and the metering wrap around it.
- **Auth**: an API key per caller, issued on signup, sent as a bearer
token. No key, no call; this is the one place v2 adds a gate v1
deliberately has none of.
- **Metering**: one row per call (key, tool, timestamp, latency, whether a
source failed) in a small Postgres table, not the local JSON counter
(`usage.py`) v1 ships with. Rate limit per key (a free tier, a paid tier
above it) enforced at the same layer that checks the key.
- **Billing**: usage-based, metered at the tool-call level (a `fred_series`
call and a `research_brief` call cost the same unit; the value is "one
research question answered," not FLOPs). Stripe metered billing or
equivalent; no card on file blocks every call past the free tier's cap.
- **What stays the same**: still read-only, still no key/account/order
access, still no hosted LLM call inside the server (FRED stays
bring-your-own-key; an LLM-backed tool, if one is ever added, would be
the same local-Claude-Code route the trading server uses, metered
separately).

## Why not now

v1's job is to prove usage exists before anyone is asked to pay or to trust
a hosted endpoint with a key. Building metering and billing before that
signal is real backfill work for a number nobody has yet. The first
concrete trigger to start v2: the `usage.json` counter (or its holder's own
report of install/call counts) shows real, sustained call volume from
outside the operator's own machine.
2 changes: 1 addition & 1 deletion pathiel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import ssl
import certifi

__version__ = "0.8.0"
__version__ = "0.9.0"

# Fix SSL cert verification on macOS (system Python lacks cacert.pem)
if not os.environ.get("NO_SSL_FIX"):
Expand Down
4 changes: 4 additions & 0 deletions scripts/build_plugin_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@
"pathiel/static/*", # the dashboard's browser assets
"pathiel/templates/*", # the dashboard's pages
"services/pathiel_data_api/*", # a separately deployed service
"services/research_mcp/*", # a second, separate plugin (its own
# .claude-plugin/plugin.json, launcher
# and bundle; see
# services/research_mcp/README.md)
)

REPO_URL = "https://github.com/Julian-dev28/pathiel"
Expand Down
32 changes: 32 additions & 0 deletions scripts/pathiel-research-mcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""pathiel research MCP -- entrypoint.

A separate process and a separate entrypoint from the trading server
(scripts/pathiel-mcp-server.py): this script does nothing but put the repo
root on sys.path and hand off to services/research_mcp/server.py, which
holds every tool and the transport. It imports NOTHING else -- no env
loader, no .env.local, no ~/.pathiel, no account or order code. See
services/research_mcp/README.md for the tool list and the install command,
and services/research_mcp/tests/test_no_trading_imports.py for the gate
that proves this whole import graph stays clean.

Run as: .venv/bin/python scripts/pathiel-research-mcp.py (a checkout), or
through scripts/pathiel-research-mcp.sh (the Claude Code plugin launcher,
which builds its own venv and runs this same file).
"""
from __future__ import annotations

import os
import sys

_SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
_ROOT = os.path.dirname(_SCRIPTS_DIR)
if _ROOT not in sys.path:
sys.path.insert(0, _ROOT)

from services.research_mcp.server import main # noqa: E402

if __name__ == "__main__":
main()
sys.stderr.flush()
os._exit(0)
52 changes: 52 additions & 0 deletions scripts/pathiel-research-mcp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# The pathiel research MCP server as a Claude Code plugin entry point.
#
# services/research_mcp/.claude-plugin/plugin.json runs this as
# "${CLAUDE_PLUGIN_ROOT}/../../scripts/pathiel-research-mcp.sh" (the plugin's
# source is the services/research_mcp/ subdirectory of this same monorepo; a
# relative-path plugin source resolves against the already-cloned repo, so
# that ../../ reaches the repo root on disk -- see the marketplace docs on
# relative-path plugin sources).
#
# Deliberately does NOT source scripts/_plugin_env.sh: that file resolves
# PATHIEL_HOME=~/.pathiel and loads the trading server's keys/config. This
# server must never touch either (CLAUDE.md: "never open .env.local or
# ~/.pathiel" for the research MCP), so it builds its own, separate venv
# under its own, separate data directory and loads no env file at all.
#
# scripts/pathiel-research-mcp.sh --bootstrap build the environment and exit
#
# Nothing is written to stdout before the exec: that channel is the MCP
# transport.
set -euo pipefail

RESEARCH_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
RESEARCH_DATA="${CLAUDE_PLUGIN_DATA:-$HOME/.pathiel-research/data}"
RESEARCH_VENV="$RESEARCH_DATA/venv"

research_fail() { echo "pathiel-research: $*" >&2; exit 1; }

py="${PATHIEL_PYTHON:-python3}"
command -v "$py" >/dev/null 2>&1 || research_fail "python3 not found; install Python 3.11 or newer (or set PATHIEL_PYTHON)"
"$py" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 11) else 1)' \
|| research_fail "$("$py" --version 2>&1) is too old; needs Python 3.11 or newer"

want="$("$py" -c 'import hashlib,sys; print(hashlib.sha256(open(sys.argv[1],"rb").read()).hexdigest())' "$RESEARCH_ROOT/requirements.lock")"
have="$(cat "$RESEARCH_VENV/.requirements.sha256" 2>/dev/null || true)"
if [ ! -x "$RESEARCH_VENV/bin/python" ] || [ "$have" != "$want" ]; then
echo "pathiel-research: building the Python environment in $RESEARCH_VENV (first run, about a minute)" >&2
mkdir -p "$RESEARCH_DATA"
"$py" -m venv "$RESEARCH_VENV" >&2 || research_fail "could not create a venv at $RESEARCH_VENV"
"$RESEARCH_VENV/bin/python" -m pip install --quiet --disable-pip-version-check \
-r "$RESEARCH_ROOT/requirements.lock" >&2 || research_fail "pip install failed; see the lines above"
printf '%s\n' "$want" > "$RESEARCH_VENV/.requirements.sha256"
echo "pathiel-research: environment ready" >&2
fi

if [ "${1:-}" = "--bootstrap" ]; then
echo "pathiel-research: ready. python=$RESEARCH_VENV/bin/python state=${PATHIEL_RESEARCH_STATE_DIR:-$HOME/.pathiel-research/state}" >&2
exit 0
fi

cd "$RESEARCH_ROOT"
exec "$RESEARCH_VENV/bin/python" scripts/pathiel-research-mcp.py "$@"
4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "io.github.Julian-dev28/pathiel",
"title": "pathiel",
"description": "AI trading agent for Hyperliquid: exact stop and target on every order. Mainnet; testnet opt-in.",
"version": "0.8.0",
"version": "0.9.0",
"repository": {
"url": "https://github.com/Julian-dev28/pathiel",
"source": "github"
Expand All @@ -12,7 +12,7 @@
"packages": [
{
"registryType": "oci",
"identifier": "ghcr.io/julian-dev28/pathiel-mcp:0.8.0",
"identifier": "ghcr.io/julian-dev28/pathiel-mcp:0.9.0",
"transport": {
"type": "stdio"
},
Expand Down
42 changes: 30 additions & 12 deletions services/intel/scheduled_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,35 @@ def merge(curated: Dict[str, Any], overlay: Dict[str, Any]) -> Dict[str, Any]:
_CACHE: Dict[Tuple[str, str], Tuple[Tuple[Any, Any], Dict[str, Any]]] = {}


def load(path: str = DATA_PATH, overlay: Optional[str] = None) -> Dict[str, Any]:
def load(path: str = DATA_PATH, overlay: Optional[str] = None, *,
use_overlay: bool = True) -> Dict[str, Any]:
"""The curated file merged with the scan overlay. Cached on both files'
(mtime, size), so a long-running process re-reads within one call of a
scan writing, and never re-parses when nothing changed."""
overlay = overlay or overlay_path()
key = (path, overlay)
sig = (_sig(path), _sig(overlay))
scan writing, and never re-parses when nothing changed.

`use_overlay=False` (added for services/research_mcp, the read-only
research MCP) skips `overlay_path()` entirely, so this call never
reaches `env.state_dir()` -> `env._load_dotenv()`, which reads the
repo's own `.env.local` into the process environment on a checkout
that has one. The research MCP must never touch that file (CLAUDE.md:
"never open .env.local or ~/.pathiel"), so it always passes
`use_overlay=False` and gets the curated file only -- no 12-hour scan
rows, which is the right trade for an external reader anyway: the scan
overlay is this operator's own live state, not a published dataset."""
if use_overlay:
overlay = overlay or overlay_path()
key: Tuple[str, str] = (path, overlay)
sig = (_sig(path), _sig(overlay))
else:
key = (path, "__no_overlay__")
sig = (_sig(path), None)
hit = _CACHE.get(key)
if hit and hit[0] == sig:
return hit[1]
with open(path) as fh:
curated = json.load(fh)
data = merge(curated, read_overlay(overlay))
overlay_data = read_overlay(overlay) if use_overlay else {"version": 1, "events": [], "state": {}}
data = merge(curated, overlay_data)
_CACHE[key] = (sig, data)
return data

Expand Down Expand Up @@ -347,11 +363,11 @@ def _for_coin(r: Dict[str, Any], coin: Optional[str]) -> Dict[str, Any]:


def market_events(start_ms: int, end_ms: int, coin: Optional[str] = None,
path: str = DATA_PATH) -> List[Dict[str, Any]]:
path: str = DATA_PATH, *, use_overlay: bool = True) -> List[Dict[str, Any]]:
"""Every event (file rows plus the generated FOMC/CPI/OPEC+) whose time or
blackout window touches [start_ms, end_ms), for `coin` when given, sorted
by time. Pure given the file."""
rows = [_row(e) for e in load(path)["events"]]
by time. Pure given the file. `use_overlay`: see load()."""
rows = [_row(e) for e in load(path, use_overlay=use_overlay)["events"]]
d0 = datetime.fromtimestamp(start_ms / 1000, tz=timezone.utc).date() - timedelta(days=2)
d1 = datetime.fromtimestamp(end_ms / 1000, tz=timezone.utc).date() + timedelta(days=2)
rows += _generated(d0, d1)
Expand All @@ -367,9 +383,11 @@ def market_events(start_ms: int, end_ms: int, coin: Optional[str] = None,
return sorted(out, key=lambda r: r["at_ms"])


def blackout(coin: str, at_ms: int, path: str = DATA_PATH) -> Optional[Dict[str, Any]]:
"""The impact-3 event window `at_ms` sits in for `coin`, or None."""
for r in market_events(at_ms - 3 * DAY_MS, at_ms + 3 * DAY_MS, coin, path):
def blackout(coin: str, at_ms: int, path: str = DATA_PATH, *,
use_overlay: bool = True) -> Optional[Dict[str, Any]]:
"""The impact-3 event window `at_ms` sits in for `coin`, or None.
`use_overlay`: see load()."""
for r in market_events(at_ms - 3 * DAY_MS, at_ms + 3 * DAY_MS, coin, path, use_overlay=use_overlay):
w = r["window"]
if w and w["start_ms"] <= at_ms < w["end_ms"]:
return {"coin": coin, "event": r["title"], "kind": r["kind"], "start_ms": w["start_ms"],
Expand Down
Loading