Metadata-Version: 2.4
Name: ohamlab-agent
Version: 0.1.1
Summary: Web research and extraction toolkit with MCP and optional autonomous LLM agents
License: MIT
Project-URL: Homepage, https://github.com/innokria/ohamlab-plugin
Project-URL: Repository, https://github.com/innokria/ohamlab-plugin
Project-URL: Documentation, https://github.com/innokria/ohamlab-plugin/tree/main/ohamlab-plugin
Project-URL: Issues, https://github.com/innokria/ohamlab-plugin/issues
Keywords: ai-agent,mcp,web-search,web-scraping,deepseek,automation,llm
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: typer>=0.12
Requires-Dist: rich>=13
Requires-Dist: httpx>=0.27
Requires-Dist: mcp>=1.0
Requires-Dist: ddgs
Requires-Dist: playwright
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: gradio
Requires-Dist: openai

# ohamlab-plugin

An independent web-data extraction service intended to connect to DeepSeek Harness (DSH) through the Model Context Protocol (MCP).

## Current Tools
```
  Tools available from OhamLab
Tool	Purpose
web_search_tool	Search the web
web_fetch	Fetch and extract a webpage
search_and_fetch_tool	Search, fetch top results, and store documents
stored_documents	List saved documents
get_document	Retrieve a saved document
task_history	Retrieve recent task history

```
## Initial capabilities

- Search the public web using the `ddgs` search library.
- Fetch public pages with Chromium, including many JavaScript-rendered pages.
- Extract readable text and basic page metadata.
- Store documents and task history in JSON files on a mounted Hugging Face Bucket volume.
- Expose search, fetch, search-and-fetch, stored-document retrieval, and task-history MCP tools.
- Provide a Gradio UI for manual testing.

This project implements its own version of a broad search → fetch → extract → store workflow. It is not a copy of TinyFish proprietary technology and does not claim feature parity or guaranteed access to every website.
## DEEPSEEK changes

## Deepseek prompt
```
Search the web for: [YOUR_QUERY_HERE]
Use the web_search_tool with:
- query: "[YOUR_QUERY_HERE]"
- max_results: [NUMBER, optional, default 5]
```
## web profile -> cordis.patch.yml
```
- insert:
    - id: free-model-rahul
      name: dsh-free-model-command


- insert:
    - id: mcp-ohamlab
      name: '@deepseek-ai/dsh-mcp-client'
      config:
        serverName: ohamlab
        transport: streamable-http
        url: 'https:/space/mcp/'
        headers:
          Authorization: !!js '`Bearer ${process.env.API_KEY}`'
        toolCallTimeoutMs: 60000
        failOnStartupError: false
        reconnect:
          enabled: true
          initialDelayMs: 500
          maxDelayMs: 30000
          maxAttempts: 10
```

```

Summary of Fixes Applied
Fix 1: Configuration — /data/dsh/profiles/web/cordis.patch.yml
Authorization env var: API_KEY 
MCP endpoint: 
https://spaceurl
Transport: streamable-http
Fix 2: Code — /app/deepseek-harness/scripts/gen-tool-catalog.ts
Added @deepseek-ai/dsh-mcp-client entry to TOOL_PACKAGES constant
The entry includes:
pkg: @deepseek-ai/dsh-mcp-client
dir: mcp-client
source: packages/mcp-client/src/index.ts
requires: ['ctx.tools', 'ctx.systemPrompt']
writes: ['tool/call', 'tool/result']
note: Describes the six OhamLab tools and MCP endpoint

```

## Code
```
ohamlab-plugin/
│
├── README.md
├── requirements.txt
├── .gitignore
├── Dockerfile
├── start.sh
│
├── app.py
│
├── config/
│   └── settings.json
│
├── mcp_server/
│   ├── __init__.py
│   ├── server.py
│   └── tools/
│       ├── __init__.py
│       └── search.py
│
├── agent/
│   ├── __init__.py
│   └── engine.py
│
├── browser/
│   ├── __init__.py
│   └── automation.py
│
├── storage/
│   ├── __init__.py
│   └── bucket.py
│
├── tests/
│   └── test_search.py
│
└── planning/
    └── design.md
```
## Run locally

Python 3.11+ is recommended.

```bash
python -m venv .venv
# Windows PowerShell: .venv\Scripts\Activate.ps1
# Linux/macOS: source .venv/bin/activate
pip install -r requirements.txt
playwright install chromium
python app.py
```

Open `http://localhost:7860`.

## Hugging Face Space deployment

1. Create a Docker Space and copy/sync this repository into the Space repository.
2. Attach a read-write Hugging Face Bucket volume and mount it at `/data`.
3. Set Space variable `OHAM_DATA_DIR=/data/ohamlab-plugin`.
4. Set Space Secret `OHAM_MCP_API_KEY` to a strong random token.
5. Rebuild the Space and verify `/health` and `/mcp`.

A Bucket is not automatically mounted by this application. Configure the mount in Hugging Face settings; the application writes under `OHAM_DATA_DIR`.

## MCP endpoint

The intended endpoint is:

`https://YOUR-SPACE-NAME.hf.space/mcp`

The MCP server uses Streamable HTTP. Configure DSH to use a remote MCP server and send:

`Authorization: Bearer YOUR_OHAM_MCP_API_KEY`

The exact DSH configuration fields depend on the installed Harness version. Verify that your DSH MCP client supports remote Streamable HTTP and custom headers. Do not expose the endpoint without authentication and do not commit tokens to GitHub.

## MCP tools

- `web_search(query, max_results=5)` — find candidate pages and return URLs/snippets.
- `web_fetch(url, save=true)` — fetch and extract a page, optionally storing it.
- `search_and_fetch(query, max_results=5, fetch_top=3)` — search, fetch the top results, and persist successful extractions.
- `stored_documents(query='', limit=10)` — list saved document metadata.
- `get_document(document_id)` — retrieve the complete saved document.
- `task_history(limit=20)` — inspect recent operations.

## Storage layout

```text
$OHAM_DATA_DIR/
├── documents/<document_id>.json
└── task-history/YYYY-MM-DD.jsonl
```

The document ID is derived from the requested URL. Fetching the same URL updates its saved record. This initial implementation does not yet keep version history for changed content.

## Security and limitations

- Only public HTTP/HTTPS URLs are intended. Basic DNS/IP checks reject obvious private destinations.
- This starter's URL checks are not a complete SSRF boundary: browser subresources, DNS rebinding, and redirect behavior need stronger isolation before accepting arbitrary untrusted URLs.
- Respect website terms, robots policies, rate limits, and applicable law.
- Do not use this service to bypass authentication or access controls.
- Search providers can throttle or change behavior.
- Browser rendering does not guarantee success on every website.
- No autonomous multi-step browser actions, scheduled monitors, or authenticated browser profiles are included in this first milestone.
