feat(serve): say where a filing was read from and where exports go - #87
Merged
Merged
Conversation
Where a filing came from. A ticker or cik:accession loads the published TAVI from the RoboSystems CDN first — RoboSystems' parse of the filing, not the filing as filed — and nothing in the answer said so. load_filing and describe_filing now return `read_from`: `published` with the URL read, or `edgar`, `file`, `url`, `filings.xbrl.org`. `--pure`, the faithful-reading profile, now parses from EDGAR unless XBRLKIT_ARTIFACTS_URL is set; the variable, empty, turns the CDN off in either profile. Where exports go. A client that launches the server picks its working directory: Claude Desktop starts it in `/`, where `output/` cannot be created, and Claude Code in the open project, where exports landed in the repo. Without --out-dir, exports now go to ~/xbrlkit/output; the folder is printed at startup, named in export_filing's description, and every export returns an absolute path. A folder that cannot be written is a tool error that says to set --out-dir.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two things the server didn't say, both found while using it from real MCP clients.
Where a filing came from. A ticker or
cik:accessionloads the published TAVI (or holon) from the RoboSystems public data CDN first. That's RoboSystems' parse of the filing, not the filing as filed, and nothing in the answer said so; the load receipt carried only"source": "V 10-K".--pure, documented as the faithful-reading profile, read it too.XBRLKIT_ARTIFACTS_URL, was documented only in a code comment.Where exports go. Without
--out-dir,servewrote to./outputrelative to whatever working directory the client chose./, so every export failed there, with nothing the model could act on.Changes
serve/session.py:LoadedFiling.read_from. A CDN load records{"kind": "published", "url": <the TAVI or holon actually read>, "note": …}.edgar,file(with the absolute path),url, orfilings.xbrl.org.serve/tools.py:describe_filingand theload_filingreceipt returnread_from._export_dirresolves the export folder to an absolute path and creates it. If it can't, it raises a tool error telling the model to restart with--out-dir.serve/server.py:DEFAULT_EXPORT_DIR = ~/xbrlkit/output, used when--out-dirisn't given.export_filing's description.cli.py:--out-dirdefaults to that folder._serve_configturns the CDN off under--pureunlessXBRLKIT_ARTIFACTS_URLis set.serve/README.md: a section on the CDN (what a published copy is and lacks,read_from, how to read the filing itself),--pure's new behavior, and where exports go and why, with an--out-direxample.README.mdandconfig.py: the same, briefly.Output Impact
CHANGED OUTPUT and CLI CONTRACT, for
serveonly:load_filinganddescribe_filinggain aread_fromobject; nothing is removed.--out-dir,export_filingnow writes to~/xbrlkit/outputrather than./output, and returns absolute paths.serve --pureparses a ticker orcik:accessionfrom EDGAR, not from the CDN.xbrlkit buildandfetchstill default to./output. Every projection is unchanged.Testing
just test-all: 667 passed, 2 skipped; ruff check, ruff format --check and basedpyright clean.main's source:test_pure_parses_from_edgar_unless_the_source_is_chosen;test_an_unwritable_export_folder_says_to_set_out_dir;test_a_file_load_says_where_it_was_read_from;test_exports_default_to_a_folder_in_home, which starts the server in/as Claude Desktop does;read_fromassertions intest_a_ticker_loads_the_published_tavi_firstandtest_an_unreachable_tavi_falls_back_to_the_holon, the second proving it records the representation actually read.test_the_newest_filing_decides_never_an_older_one_with_a_holonnow asserts the EDGAR origin; its fake loaded filing gained the field.xbrlkit serve --transport stdiostarted with working directory/and no--out-dir, driven by an MCP stdio client, loading MariMed's 10-K1522767:0001522767-26-000030.read_fromispublished, with thetavi.jsonURL read, and thelpgexport landed at an absolute path under~/xbrlkit/output.--pure:read_fromisedgar, and the export landed in the same folder.exports: …at startup.