Read-only Model Context Protocol (MCP) server for GRACC, the OSG accounting system.
This server gives MCP-compatible AI clients safe access to public GRACC accounting data through the documented public OpenSearch-compatible endpoint:
https://gracc.opensciencegrid.org/q
It serves two datasets:
jobs(the default): OSG job accounting fromgracc.osg.summary: core hours, job counts, CPU and wall time, GPU hoursosdf: Open Science Data Federation transfers from the dailyosdf-summary-*indices: bytes read and written, and transfer counts
It also offers lookups of OSG Topology project and VO metadata and OSG's institution database (field of science, organization, and institution metadata), so a client can say what science and which institutions a usage number represents.
The implementation is intentionally conservative:
- read-only only
- explicit per-dataset index allowlists
- aggregation-first workflows
- hard validation and safety caps
- standards-compliant MCP tool definitions
- portable STDIO-first design, with optional Streamable HTTP
Run the published image:
docker run --rm -p 3333:3333 ghcr.io/opensciencegrid/gracc-mcp-server:latestThen point any MCP client that supports Streamable HTTP at http://localhost:3333/mcp. For example, with Claude Code:
claude mcp add --transport http gracc http://localhost:3333/mcpTo run without a network listener, build from source and register the server over STDIO instead; see Setup and Other MCP Client Notes.
Questions to try:
- "Which VOs used the most core hours in October 2026?"
- "Show weekly GPU hours for the last three months."
- "How many jobs did LIGO run last week, and how many core hours did they use?"
- "Which OSDF namespaces read the most data last month?"
- "Show daily OSDF bytes read for the /ospool namespace over the last two weeks."
- "What ran at the site Nebraska last month, what fields of science were they, and which institutions did they come from?"
More examples are in examples/prompts.md. A good first call for a new client is list_dimensions, which returns the valid filter, grouping and metric ids for a dataset.
GRACC is the Open Science Grid accounting system. It collects and summarizes usage data and exposes public read-only query access for analytics. The GRACC docs explicitly document the public query endpoint and show aggregation examples over fields such as EndTime, VOName, ResourceType, CoreHours, and Njobs.
This MCP server wraps a small, safe subset of that public query surface into model-friendly tools:
list_dimensionsquery_usage_summarytop_n_entitiestime_series_usageget_schema_notesrun_safe_queryfind_valuessearch_projects,search_institutions,search_vos(metadata lookups)
The server is designed for LLM tool use, not for raw admin access or dashboard mirroring.
Every tool takes an optional dataset argument: jobs (default) or osdf. Omitting it behaves exactly as before the OSDF dataset was added. Dimension, metric and date field ids are specific to a dataset; list_dimensions returns them.
Lists supported filter fields, grouping fields, date fields, and metrics for a dataset, plus the datasets the server offers (available_datasets).
Good first call for a client that needs to discover valid arguments before issuing analytical queries.
Returns aggregate usage metrics over a required time range with optional exact-match filters.
Example use cases:
- total
core_hoursforvo_name=ligo - total
job_countforresource_type=Payload - total
cpu_duration_secondsfor a project over a week - total
bytes_readandtransfer_countfornamespace=/ospool(datasetosdf)
Ranks the top N values for a supported dimension using a selected metric.
Example use cases:
- top VOs by
core_hours - top projects by
job_count - top sites by
wall_duration_seconds - top OSDF namespaces or client domains by
bytes_read(datasetosdf)
Returns a date histogram over a required time range and metric.
Supported intervals:
dayweekmonth
Returns concise notes, caveats, and source references derived from public GRACC docs and observed public mappings.
Expert tool for constrained raw _search access. It can be turned off with GRACC_ENABLE_SAFE_QUERY=false.
The caller's JSON is never forwarded. The server validates each part and builds a fresh request from it, so any key it does not recognize is rejected rather than passed through to GRACC.
Requirements:
queryis required and must contain arangeon the dataset's date field (EndTimeor@timestampforjobs,@timestampforosdf) with both a lower (gte/gt) and upper (lt/lte) bound, either as the top-level query or insidebool.filter. A range insidemust_notdoes not count.- The bounded range must be at most
GRACC_MAX_RANGE_DAYSlong. - Date values must be strict ISO 8601 (
2026-04-01or2026-04-01T12:00:00Z). Epoch numbers and date math such asnow-7dare rejected.
It only allows:
- allowlisted index selection
- the selected dataset's allowlisted fields (ids such as
vo_nameornamespaceare resolved to field names such asVONameordirname1) term,terms(at mostGRACC_MAX_FILTER_VALUES, 500 by default),range, andboolwithfilter/must_not(at most 3 levels deep, 32 clauses total)termsaggregations withfield,size(at mostGRACC_MAX_TOP_N), andorder(_count,_key, or a child metric aggregation)date_histogramaggregations withfield(a date field that has a bounded range in the query),calendar_interval(day,week,month), andtime_zonesum(metric fields only) andvalue_countaggregations withfield- at most 10 aggregations, nested at most 2 deep, with an estimated total of at most 10,000 buckets
sizedefaults to0; when hits are requested,_sourceis limited to allowlisted fields
It rejects:
- writes, updates, deletes, and endpoints other than
_search - scripts anywhere, including inside aggregations
query_stringand any other unsupported query operator- aggregation options such as
extended_bounds,min_doc_count,shard_size,include,exclude, andmissing - result payloads above
GRACC_MAX_RESULT_BYTES
Finds values of a dimension that contain some text, case-insensitively, with their usage over a date range. Use it to turn a partial name into exact values for other tools' filters: oim_site containing "Nebraska" returns Nebraska-CMS and Nebraska-Omaha.
- Searchable dimensions,
jobs:site_name,oim_site,resource_group,project_name,vo_name,reportable_vo_name,probe_name,submit_host.osdf:namespace,site,server_hostname,user_domain.common_nameis not searchable, because it can identify people. containsis 1–64 characters: letters, digits, space, and. _ - /. The server builds the match pattern itself and treats punctuation literally.
These answer "what science" and "which institutions" for usage numbers. They read an in-memory copy of three public feeds that the server refreshes periodically (GRACC_TOPOLOGY_REFRESH_SECONDS), and every result includes data_as_of. Until the first load completes, they return "Topology metadata is not loaded yet"; the usage tools are unaffected.
search_projects: OSG Topology projects with field of science, organization, department and sponsor, plus each project's institution. Passnames(case-insensitive, up to 500) to annotate a usage result in one call; names that aren't projects come back innot_found.search_institutions: institutions from OSG's institution database, with their projects.available_attributeslists the metadata keys present, whichinstitution_attributescan filter on.search_vos: VOs with long name, community description, fields of science, parent VO and URL. VOs have no structured institution;communityis free text that often names one.
Institution metadata (ipeds_metadata, US federal IPEDS data, and carnegie_metadata, Carnegie classifications) is passed through exactly as OSG's institution database provides it. null means unknown, never "no", and unknown never matches an institution_attributes filter. People are never returned: no PI names, VO contacts or managers.
Joining metadata to usage:
- Project metadata applies to
jobsrecords withresource_type=Payload. - GRACC project names can differ in case from Topology's;
search_projectsmatches case-insensitively. project_namevalues such ascmsandosgare VO-level placeholders; usesearch_vosfor them.
Worked example, "What ran at Nebraska last month, and what science was it?":
find_valueswithdimension: "oim_site",contains: "Nebraska"returnsNebraska-CMSandNebraska-Omaha.top_n_entitieswithdimension: "project_name",filters: { oim_site: [those sites], resource_type: "Payload" }andlimit: 500returns every project's core hours.search_projectswith thosenamesgives each project's field of science and institution.search_voswith thenot_foundnames (such ascms) describes the VO-level usage.
Each dataset queries only its own allowlisted index:
jobs: thegracc.osg.summaryalias (GRACC_DEFAULT_INDEX,GRACC_ALLOWED_INDICES)osdf: theosdf-summary-*pattern (GRACC_OSDF_INDEX)
Observed public mappings on 2026-04-22 showed backing summary indices such as yearly gracc.osg.summary4-* indices, but the server intentionally targets the documented alias rather than those backing indices directly.
The osdf-summary-* indices are daily summaries that OpenSearch transforms build from the raw per-file-close OSDF monitoring records. The server never queries the raw records, which contain usernames, file paths and client addresses.
Primary dimensions:
vo_name->VONamereportable_vo_name->ReportableVONameproject_name->ProjectNameresource_type->ResourceTypecommon_name->CommonNamesite_name->SiteNameoim_site->OIM_Siteresource_group->OIM_ResourceGroupsubmit_host->SubmitHostprobe_name->ProbeNameend_time->EndTimetimestamp->@timestamp
Primary metrics:
job_count-> sum ofNjobscore_hours-> sum ofCoreHourswall_duration_seconds-> sum ofWallDurationcpu_duration_seconds-> sum ofCpuDurationcpu_user_seconds-> sum ofCpuDuration_usercpu_system_seconds-> sum ofCpuDuration_systemprocessor_count_sum-> sum ofProcessorsgpu_hours-> sum ofGPUHoursgpu_count_sum-> sum ofGPUs
Dimensions:
namespace->dirname1(top-level namespace, such as/ospoolor/igwn)site->site(cache or origin site)server_hostname->server_hostnameuser_domain->user_domain(client DNS domain, such aswisc.edu)timestamp->@timestamp(the UTC day of each summary record; the only date field)
Metrics:
bytes_read-> sum ofread_sumbytes_written-> sum ofwrite_sumbytes_read_vectored-> sum ofreadv_sumtransfer_count-> sum ofdoc_count(one transfer record per file close)
Deeper path fields (dirname2, logical_dirname) are not exposed because they often contain usernames, and server is not exposed because it is mostly 127.0.0.1.
The summary documents are pre-aggregated and carry _doc_count, so for osdf the matched_documents values count transfer records rather than summary documents.
- Node.js
20.11+ - npm
10+
npm installnpm run buildnpm run testOptional live test against the public endpoint:
GRACC_LIVE_TESTS=1 npm run test:liveFor local MCP clients that spawn the server as a subprocess:
npm run dev:stdioOr after building:
npm run start:stdioOptional stateless Streamable HTTP endpoint:
npm run dev:httpOr after building:
npm run start:httpDefault URL:
http://127.0.0.1:3333/mcp
Published image: ghcr.io/opensciencegrid/gracc-mcp-server
docker run --rm -p 3333:3333 ghcr.io/opensciencegrid/gracc-mcp-server:latestThe image runs the HTTP transport and listens on 0.0.0.0:3333 (path /mcp). Pass any GRACC_* setting from Configuration with -e, for example -e GRACC_RATE_LIMIT_MAX=60.
To build it yourself:
docker build -t gracc-mcp-server .This repository includes a GitHub Actions workflow at .github/workflows/docker.yml.
It does two things:
- builds the Docker image on every push, pull request, and manual workflow run
- pushes the image to GitHub Container Registry on pushes to the default branch and on tag pushes
Published image: ghcr.io/opensciencegrid/gracc-mcp-server
Published tags:
latestandmainon the default branch1.2.3and1.2when av1.2.3git tag is pushedsha-<commit>for every published commit
Pin a sha-<commit> or version tag for deployments rather than latest.
The manifests under k8s/ are a generic example you can adapt:
k8s/base: Deployment, ConfigMap and two ClusterIP Servicesk8s/overlays/dev: a standalonegracc-mcpnamespace using the published imagek8s/overlays/nrp: an NRP Nautilus deployment behind the Envoy AI Gateway
OSG's hosted instance is deployed from separate cluster configuration, not from these overlays.
The example deployment runs two containers in one pod:
gracc-mcpon port3333for the native MCP endpointmcpoon port8000as an optional MCP-to-OpenAPI bridge for Open WebUI and other OpenAPI clients. Remove it if you only need MCP.
Deploy:
kubectl apply -k k8s/overlays/devThe deployment creates two cluster-internal services:
gracc-mcp:3333-> native MCP endpoint at/mcpgracc-mcp-openapi:8000-> OpenAPI bridge with docs at/docs
In-cluster URLs:
http://gracc-mcp:3333/mcphttp://gracc-mcp-openapi:8000/docs
The bundled mcpo sidecar uses the Open WebUI-maintained MCP-to-OpenAPI proxy image:
ghcr.io/open-webui/mcpo:main
If you need external access, add your own Ingress, Gateway, or service-type override in an overlay rather than changing the base manifests.
Copy .env.example to .env and adjust only if needed.
Important settings:
GRACC_BASE_URLGRACC_DEFAULT_INDEXGRACC_ALLOWED_INDICESGRACC_MAX_RANGE_DAYSGRACC_MAX_BUCKETSGRACC_MAX_TOP_NGRACC_MAX_SAFE_QUERY_SIZEGRACC_MAX_RESULT_BYTESGRACC_TIMEOUT_MSGRACC_RETRY_COUNTGRACC_HTTP_HOSTGRACC_HTTP_PORT
Public deployment settings:
| Variable | Default | Purpose |
|---|---|---|
GRACC_ENABLE_SAFE_QUERY |
true |
Register the expert run_safe_query tool. |
GRACC_ENABLE_OSDF |
true |
Offer the osdf dataset. When false, requests for it are rejected and list_dimensions does not list it. |
GRACC_OSDF_INDEX |
osdf-summary-* |
Index or pattern holding the OSDF daily summaries; the only index the osdf dataset may query. |
GRACC_MAX_TOP_N |
500 |
Largest limit for top_n_entities, find_values and the lookups, and largest terms.size in run_safe_query. |
GRACC_MAX_FILTER_VALUES |
500 |
Most values one filter (or a run_safe_query terms clause) may list. |
GRACC_ENABLE_TOPOLOGY |
true |
Offer search_projects, search_institutions and search_vos. |
GRACC_TOPOLOGY_URL |
https://topology.opensciencegrid.org |
OSG Topology base URL; /miscproject/json and /vosummary/json are read from it. |
GRACC_INSTITUTIONS_URL |
https://topology-institutions.osg-htc.org/api/institution_ids |
OSG's institution database feed. |
GRACC_TOPOLOGY_REFRESH_SECONDS |
3600 |
How often the metadata is refreshed, kept between 60 seconds and 1 day; 0 loads once at startup and never refreshes. A failed refresh keeps the last good copy and logs one line to stderr. |
GRACC_TOPOLOGY_MAX_BYTES |
10485760 |
Largest metadata feed the server will read. |
GRACC_TRUST_PROXY |
false |
Express trust proxy value. Set to the number of proxy hops (usually 1 behind an ingress) so rate limits use the real client IP. Avoid true, which lets clients spoof X-Forwarded-For. |
GRACC_RATE_LIMIT_MAX |
120 |
HTTP requests per client IP per window. 0 disables rate limiting. |
GRACC_RATE_LIMIT_WINDOW_MS |
60000 |
Rate limit window. |
GRACC_MAX_CONCURRENT_UPSTREAM |
4 |
Maximum simultaneous requests to GRACC per process. |
GRACC_MAX_QUEUED_UPSTREAM |
32 |
Requests allowed to wait for a slot; beyond this the tool returns a "busy" error. |
GRACC_MAX_UPSTREAM_BYTES |
1048576 |
Largest GRACC response the server will read. |
GRACC_CACHE_TTL_SECONDS |
300 |
How long identical queries are served from memory. 0 disables the cache. |
GRACC_CACHE_MAX_BYTES |
33554432 |
Memory budget for the response cache. |
Rate limits, the cache, and the concurrency cap are per process, so with N replicas GRACC can see up to N × GRACC_MAX_CONCURRENT_UPSTREAM concurrent requests. If the server sits behind a gateway that does not forward client IPs, every request shares one rate limit bucket. In that case, raise GRACC_RATE_LIMIT_MAX or set it to 0 and limit at the gateway.
This server is intentionally read-only.
Core protections:
- only
_searchis used - each dataset has an explicit index allowlist, and raw OSDF records are never queried
- no write or admin APIs are implemented
- required date ranges for analytical tools, in strict ISO 8601 and converted to UTC before they are sent upstream, so JavaScript and OpenSearch cannot disagree about what a date means
- hard caps on date range, bucket count, top N, and raw query size
- exact-match filters only in normal tools
run_safe_querybuilds a fresh request from validated parts instead of forwarding the caller's JSON- per-IP rate limiting on the HTTP endpoint
- a process-wide cap on concurrent GRACC requests, with a bounded wait queue
- identical concurrent queries share one GRACC request, and successful responses are cached briefly
- GRACC responses are read with a byte cap
- request timeout; only connection failures and 429/502/503/504 responses are retried, with backoff. Query errors and timeouts are not retried, and a
Retry-Afterlonger than 5 seconds is not waited out - result payload size cap for
run_safe_query - metadata lookups read an in-memory copy of public feeds, fetched with a timeout and byte cap and never per request; people's names and contacts are dropped when the feeds load
find_valuesbuilds its own match pattern from restricted input, andrun_safe_querystill rejects client-suppliedincludepatterns
gracc.osg.summaryis the authoritative public alias used by this server.EndTimeis the default time field because it is used in the public GRACC direct-query examples.CoreHoursis used directly from the public mapping instead of being derived.ProjectName,ReportableVOName,OIM_Site, and related fields may already reflect GRACC correction and enrichment stages.
@timestampis available from the public mappings but appears to be ingest-oriented, not job-end-oriented.processor_count_sumis a sum ofProcessorsacross matching summary documents, not a distinct hardware inventory count.CommonNamemay be high-cardinality and is often less useful for broad analytics than VO, project, or site fields. It can also be sensitive from a privacy perspective even though the endpoint is public, so prefer higher-level dimensions where they answer the question.- Public field caps showed some legacy non-
graccindices with different field types; this server avoids them.
- A transfer served by a cache that first fetched the file from an origin may also be reported by the origin, so totals across caches and origins can count the same data more than once. This has not been verified.
- Whether
bytes_readalready includes vector-read bytes (bytes_read_vectored) has not been verified; report them separately. server_hostnameis oftenlocalhostfor containerized caches; prefersite.- Transfers whose namespace could not be determined are grouped under "unknown directory".
- Is
CommonNamethe best default "submitter" dimension for every downstream use? Checking GRACC dashboards or asking site stakeholders would settle it. - Should dimensions like
PayloadSiteNameorExecutePooljoin the allowlist? Current public dashboards and usage examples would show whether they are needed. - If public docs standardize other summary aliases, update
GRACC_ALLOWED_INDICESand the schema registry together rather than loosening query validation.
These parts are portable across MCP-compatible clients:
- tool registration and schemas
- STDIO transport
- Streamable HTTP transport
- JSON result formatting
- read-only tool behavior
The core server does not depend on Codex-only APIs or prompt conventions.
These are examples only:
examples/codex/config.tomlexamples/claude-desktop-config.jsonexamples/prompts.mdk8s/deployment manifests
Different clients may vary in:
- tool-calling frequency
- schema strictness
- argument coercion
- error rendering
- support for STDIO vs HTTP transports
To stay portable, this server favors:
- explicit required dates
- small enums
- flat JSON outputs
- exact-match filters
- conservative errors
Sample .codex/config.toml snippet:
[mcp_servers.gracc]
command = "node"
args = ["/absolute/path/to/gracc-mcp/dist/index.js"]
cwd = "/absolute/path/to/gracc-mcp"See examples/codex/config.toml for a fuller example.
See examples/claude-desktop-config.json for a STDIO registration example.
Over HTTP, with the server or container running:
claude mcp add --transport http gracc http://localhost:3333/mcpOver STDIO, after npm run build:
claude mcp add gracc -- node /absolute/path/to/gracc-mcp/dist/index.jsUse either:
- STDIO mode pointing to
dist/index.js - Streamable HTTP mode pointing to
http://127.0.0.1:3333/mcp
If a client has strict schema handling, prefer calling list_dimensions first and pass only the returned ids.
.
├── .dockerignore
├── AGENTS.md
├── Dockerfile
├── LICENSE
├── README.md
├── examples/
│ ├── claude-desktop-config.json
│ ├── codex/
│ │ └── config.toml
│ └── prompts.md
├── k8s/
│ ├── base/
│ └── overlays/
├── src/
│ ├── client/
│ ├── config/
│ ├── http/
│ ├── mcp/
│ ├── query/
│ ├── schema/
│ ├── tools/
│ ├── utils/
│ ├── validation/
│ ├── http-server.ts
│ └── index.ts
└── tests/
├── fixtures/
├── integration/
├── live/
└── unit/
- GRACC Direct Queries
- GRACC Message Queues
- GRACC Operations
- OSG Topology
- MCP TypeScript SDK
- Model Context Protocol
Licensed under the Apache License, Version 2.0.