Metadata-Version: 2.4
Name: gliner2-mcp
Version: 0.1.0
Summary: MCP server exposing GLiNER2 entity extraction, classification, and JSON parsing.
Project-URL: Homepage, https://mrorigo.github.io/gliner2-mcp
Project-URL: Repository, https://github.com/mrorigo/gliner2-mcp
Author: gliner2-mcp contributors
License: MIT License
        
        Copyright (c) 2026 gliner2-mcp contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: classification,gliner2,mcp,ner,nlp
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Requires-Dist: gliner2
Requires-Dist: mcp
Requires-Dist: requests
Requires-Dist: urllib3
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

# gliner2-mcp

MCP server that exposes GLiNER2 entity extraction, classification, and JSON extraction as tools.

## Quickstart

1. Install dependencies:

```bash
uv sync
```

2. Run the MCP server:

```bash
uv run gliner2-mcp
```

## Environment configuration

This server is configured via environment variables (optionally loaded from `.env`).

| Variable | Default | Description |
| --- | --- | --- |
| `GLINER2_MODEL_ID` | `fastino/gliner2-base-v1` | GLiNER2 model id or path. |
| `GLINER2_DEVICE` | empty | Device override passed to `from_pretrained` when supported. |
| `GLINER2_MAX_TEXT_LENGTH` | `0` | Maximum input length. `0` disables the limit. |
| `GLINER2_MCP_LOG_LEVEL` | `INFO` | Log level for server logging. |
| `GLINER2_MCP_ENV_FILE` | empty | Path to an env file to load before reading the variables above. |

If `GLINER2_MCP_ENV_FILE` is not set, the server will load `.env` from the working directory when it exists.

## MCP tools

- `extractEntities(text, labels)` returns a mapping of label to entity spans.
- `classifyText(text, schema)` returns a mapping of field name to chosen label or list of labels.
- `extractJson(text, schema)` returns a JSON object that matches the provided schema.

## Available Models

[GLiNER2 family models on Hugging Face](https://huggingface.co/collections/fastino/gliner2-family)

## Development

```bash
uv sync --dev
uv run ruff check .
```

## Testing

Run the default test suite (unit + contract tests):

```bash
uv sync --extra dev
uv run --extra dev pytest -q
```

Run real-model integration tests (downloads/loads actual GLiNER2 weights):

```bash
GLINER2_MCP_RUN_INTEGRATION=1 uv run --extra dev pytest -q -m integration
```

Recommended pre-release check:

```bash
uv run --extra dev pytest -q
GLINER2_MCP_RUN_INTEGRATION=1 uv run --extra dev pytest -q -m integration
```

## License

MIT. See `LICENSE`.
