> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Supply tools and source context

> Use built-in abilities for text, files, tools, and approved MCP resources.

Built-in abilities return configured ability uses. Add them to `defineHarness({ abilities: [...] })`; the runtime binds them for each run. Tool availability and permission are separate: supplying a tool does not grant execution.

## Choose a preset or ability

| Export | Required options | Behavior |
| - | - | - |
| `base(options?)` | None | Definition with optional `id`, `abilities`, and `defaults`; ID defaults to `agentium/base`. No implicit model, tools, or jobs. |
| `research(options?)` | None | Combines optional `text`, `files`, `tools`, and additional abilities; ID defaults to `agentium/research`. |
| `textContext(options, config?)` | `id`, `entries` | Static entries with `id`, `text`, and optional `uri`. Portable with an explicit instance ID. |
| `fileContext(options, config?)` | `id`, absolute `root`, `files` | Reads approved UTF-8 paths beneath a canonical root. Requires `filesystem:read`. Local only. |
| `suppliedTools(options, config?)` | `tools` | Binds existing `ToolDef` objects; optional `requirements`. Local only. |
| `mcpResources(options, config?)` | Connection, grants, and authorization | Reads explicitly approved text resources over a host-provided MCP client. Local only. |

`research()` disables `filesystem`, `contextFiles`, `fileMemory`, and `subagents` by default. Explicit `defaults` can override those choices. Its built-in instance IDs are `research-text`, `research-files`, and `research-tools`; avoid reusing those IDs in additional abilities.

## Read project files

This factory builds a runtime but does not run it. Call `run()` with verified identity and a session to read the files and invoke the Agent.

```typescript theme={null}
import { resolve } from "node:path";
import { openai } from "@agentium/core";
import { agentDriver, defineHarness, fileContext, HarnessRuntime } from "@agentium/harness";

export function projectReader(projectDirectory: string) {
  return new HarnessRuntime({
    definition: defineHarness({
      id: "project-reader",
      abilities: [fileContext({
        id: "project-files",
        root: resolve(projectDirectory),
        files: ["README.md"],
      }, { instanceId: "readme" })],
    }),
    driver: agentDriver({
      name: "reader",
      model: openai(process.env.OPENAI_MODEL ?? "gpt-6.1-sol"),
      instructions: "Answer from the supplied project files.",
    }),
    requirements: ["filesystem:read"],
    grants: { toolIds: [], modelRoles: ["main"] },
  });
}
```

`fileContext` checks canonical paths against its root, rejects invalid or duplicate file selections, and bounds reads. File contents become source entries with URI/version metadata. This is application-level path containment; use a separate process or sandbox when you need OS isolation.

## Supply existing tools

```typescript theme={null}
import type { ToolDef } from "@agentium/core";
import { defineHarness, suppliedTools } from "@agentium/harness";

export function withTools(tools: readonly ToolDef[]) {
  return defineHarness({
    id: "tool-assistant",
    abilities: [suppliedTools({ tools }, { instanceId: "host-tools" })],
  });
}
```

Set `grants.toolIds` to the intended `ToolDef.name` values when constructing the runtime. `requiredToolIds` additionally makes missing tools a setup error. The runtime also accepts a direct `tools` array; duplicate names across direct tools and abilities are rejected.

## Connect MCP resources

Provide a principal-scoped connection factory and authorization function. This example is an integration factory: your host implements both callbacks and supplies a connected client.

```typescript theme={null}
import { defineHarness, mcpResources, type MCPResourcesOptions } from "@agentium/harness";

export function policyResources(
  connect: MCPResourcesOptions["connect"],
  authorize: MCPResourcesOptions["authorize"],
) {
  return defineHarness({
    id: "policy-reader",
    abilities: [mcpResources({
      id: "approved-policies",
      connect,
      authorize,
      connectTimeoutMs: 5000,
      resources: [{ uri: "policy://support/refunds", mimeTypes: ["text/plain"] }],
    }, { instanceId: "policies" })],
  });
}
```

`connect(ctx)` returns `{ client, dispose? }`. Setup defaults to a 5,000 ms timeout; valid values are 1–120,000 ms. A late connection is disposed if setup was cancelled. The binding disposes its connection at the end of the run.

Resource URIs and MIME types are exact allowlists. Wildcard MIME types are rejected; include `""` only if you intentionally accept responses without a MIME type. `select(query, ctx)` may choose a subset of declared URIs; duplicate or undeclared selections fail. Authorization runs before reads and before content is returned, including subsequent fetches. This ability does not discover resources across a server, turn resources into tools, or fetch their URIs over HTTP.

## Understand context bounds and trust

Runtime retrieval shares a budget across all context sources: **32 entries, 65,536 bytes, an estimated 16,000 tokens, and 5,000 ms**. These are the current runtime retrieval defaults, not fields you can configure through `HarnessRuntimeConfig`. A source receives the remaining budget in `fetch()` and should honor its abort signal.

The runtime wraps context with source and entry IDs plus optional URI/version/locator metadata. Retrieved content is always treated as source data, even if an entry claims `trust: "host"`. Invalid, expired, or failed entries can be discarded; oversized text can be truncated. Providers receive source data separately from host prompt fragments.

Use a [context policy](/harness/policies) to project bounded requests without modifying canonical history. For exact option shapes, see [presets and context reference](/harness/api/presets).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.