|
| 1 | +# Configuration |
| 2 | + |
| 3 | +Both adapters share the settings below. |
| 4 | + |
| 5 | +## Where settings come from |
| 6 | + |
| 7 | +Settings are read from the process environment. A `.env` file fills that |
| 8 | +environment; a real environment variable wins over the same name in a file. |
| 9 | + |
| 10 | +**Env file** |
| 11 | + |
| 12 | +| `OSW_ENV_FILE` | CLI | MCP server | |
| 13 | +| --- | --- | --- | |
| 14 | +| set | loads that file, searches nowhere | loads that file, searches nowhere | |
| 15 | +| unset | searches upward from the working directory | searches nowhere | |
| 16 | + |
| 17 | +**Credential file.** The first step that produces a file wins: |
| 18 | + |
| 19 | +1. `OSW_CRED_FILEPATH` or an alias, set in the environment or the env file. |
| 20 | + The run fails if this file has no entry for `OSW_DOMAIN`. That check is |
| 21 | + skipped when `OSW_USERNAME` and `OSW_PASSWORD` are both set. |
| 22 | +2. CLI only: `accounts.pwd.yaml` in the working directory. Parent directories |
| 23 | + are not searched. This step is skipped when `OSW_USERNAME` or |
| 24 | + `OSW_PASSWORD` is set. If the file has no entry for `OSW_DOMAIN` it is |
| 25 | + ignored and the run continues. |
| 26 | +3. No credential file. |
| 27 | + |
| 28 | +**Source report.** Both adapters write to stderr before connecting. The first |
| 29 | +line is labelled `credential file` when a file was found: |
| 30 | + |
| 31 | +- `<path> (from the OSW_CRED_FILEPATH environment variable)` |
| 32 | +- `<path> (from OSW_CRED_FILEPATH in the env file)` |
| 33 | +- `<path> (accounts.pwd.yaml found in the working directory)` |
| 34 | +- `<path> (accounts.pwd.yaml found in the working directory, ignored: no entry for domain '<domain>')` |
| 35 | + |
| 36 | +and `credentials` when none was: |
| 37 | + |
| 38 | +- `OSW_USERNAME/OSW_PASSWORD (from the environment)` |
| 39 | +- `OSW_USERNAME/OSW_PASSWORD (from the env file)` |
| 40 | +- `not configured (set OSW_CRED_FILEPATH, or OSW_USERNAME/OSW_PASSWORD)` |
| 41 | + |
| 42 | +The second line is labelled `env file`. Which lines appear depends on the |
| 43 | +adapter: |
| 44 | + |
| 45 | +- **CLI**: the first line only. `--verbose`, or a command that fails, adds |
| 46 | + the second. |
| 47 | +- **MCP server**: neither, since its sources are fixed in the server entry. |
| 48 | + `OSW_VERBOSE=true` prints both, and a failed start prints both regardless. |
| 49 | + |
| 50 | +A verbose run of the CLI prints: |
| 51 | + |
| 52 | +```text |
| 53 | +[osw] credential file: /home/me/project/accounts.pwd.yaml (accounts.pwd.yaml found in the working directory) |
| 54 | +[osw] env file : /home/me/project/.env (found from the working directory upward) |
| 55 | +``` |
| 56 | + |
| 57 | +The prefix names the adapter that printed the line: `[osw]` for the CLI, |
| 58 | +`[osw-mcp]` for the MCP server. This holds for every message the two share, |
| 59 | +not only these two lines. |
| 60 | + |
| 61 | +## Where messages go |
| 62 | + |
| 63 | +The source report above is printed directly, because the adapter's own verbose |
| 64 | +flag decides whether it appears, not the log level. |
| 65 | + |
| 66 | +Every other message the adapters produce goes to the `osw` logger, together |
| 67 | +with the records of the library itself. A failed connection check and an |
| 68 | +unreadable provenance ledger are reported that way. `OSW_LOG_LEVEL` sets how |
| 69 | +much of it appears, and an application that configures logging itself takes the |
| 70 | +records over. See [Logging](../get-started.md#logging). |
| 71 | + |
| 72 | +Both kinds of message are written to stderr, never to stdout. The MCP server |
| 73 | +speaks JSON-RPC over stdout, and the CLI writes its `--json` output there, so |
| 74 | +stdout has to stay free. |
| 75 | + |
| 76 | +## Credentials |
| 77 | + |
| 78 | +Keep credentials in a gitignored file. They are read once per process, into that |
| 79 | +process only, and never written back to disk. Set either `OSW_USERNAME` and |
| 80 | +`OSW_PASSWORD`, or `OSW_CRED_FILEPATH`. |
| 81 | + |
| 82 | +A credential file uses the YAML format osw's `CredentialManager` reads, keyed |
| 83 | +by iri (default file name: `accounts.pwd.yaml`): |
| 84 | + |
| 85 | +```yaml |
| 86 | +wiki-dev.open-semantic-lab.org: |
| 87 | + username: your-user |
| 88 | + password: your-password |
| 89 | +``` |
| 90 | +
|
| 91 | +A credential file may hold several iris. The CLI selects one automatically if it |
| 92 | +is the only one, and otherwise requires `osw --instance <iri>`. The MCP server |
| 93 | +never selects one, see [One server per instance](mcp.md). |
| 94 | + |
| 95 | +## Variable reference |
| 96 | + |
| 97 | +The canonical variable names are `OSW_*`. Older `OSW_MCP_*` and `OSL_*` names |
| 98 | +stay accepted so existing deployments keep working, and the first name that is |
| 99 | +set wins: |
| 100 | + |
| 101 | +| Canonical | Also accepted | Meaning | |
| 102 | +| --- | --- | --- | |
| 103 | +| `OSW_DOMAIN` | `OSL_DOMAIN` | Instance to connect to. A bare host (`wiki.example.org`) or a full URL (`https://wiki.example.org/w/`); the host is taken from either, and a value no host can be read from (`https://`, `/w/index.php`) is rejected at startup | |
| 104 | +| `OSW_USERNAME` | `OSL_USERNAME` | Login user | |
| 105 | +| `OSW_PASSWORD` | `OSL_PASSWORD` | Login password | |
| 106 | +| `OSW_CRED_FILEPATH` | `OSW_MCP_CRED_FILEPATH`, `OSL_CRED_FILEPATH` | YAML credential file, keyed by iri (falls back to `accounts.pwd.yaml` in the working directory, CLI only) | |
| 107 | +| `OSW_ENV_FILE` | `OSW_MCP_ENV_FILE` | `.env` file to load | |
| 108 | +| `OSW_READ_ONLY` | `OSW_MCP_READ_ONLY` | `true` refuses every write | |
| 109 | +| `OSW_SPARQL_ENDPOINT` | | Endpoint for `sparql` queries | |
| 110 | +| `OSW_STATE_DIR` | `OSW_MCP_STATE_DIR` | Where the provenance ledger is kept. Must be an absolute path; a leading `~` is expanded | |
| 111 | +| `OSW_MAX_RESULTS` | `OSW_MCP_MAX_RESULTS` | Default result cap (100) | |
| 112 | +| `OSW_MAX_CHARS` | `OSW_MCP_MAX_CHARS` | Result size cap in characters (100000) | |
| 113 | +| `OSW_VERBOSE` | `OSW_MCP_VERBOSE` | `true` prints the configuration source report | |
| 114 | + |
| 115 | +## Windows paths in a `.env` file |
| 116 | + |
| 117 | +Quote them with single quotes, or leave them unquoted. A double-quoted value is |
| 118 | +escape-decoded, so `\a` in a path silently becomes a BEL byte that renders as |
| 119 | +nothing: |
| 120 | + |
| 121 | +```dotenv |
| 122 | +OSW_CRED_FILEPATH='C:\Users\me\accounts.pwd.yaml' # ok |
| 123 | +OSW_CRED_FILEPATH=C:\Users\me\accounts.pwd.yaml # ok |
| 124 | +OSW_CRED_FILEPATH="C:\Users\me\accounts.pwd.yaml" # broken: \a is eaten |
| 125 | +``` |
0 commit comments