netdocai 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,585 @@
1
+ Metadata-Version: 2.4
2
+ Name: netdocai
3
+ Version: 0.1.0
4
+ Summary: Autonomous AI-powered network troubleshooting CLI
5
+ Author: Abhishek Anand
6
+ Requires-Python: >=3.11
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: python-dotenv
9
+ Requires-Dist: google-genai
10
+ Requires-Dist: mcp[cli]
11
+ Requires-Dist: langgraph
12
+ Requires-Dist: chromadb
13
+ Requires-Dist: rich
14
+
15
+ # NetDocAI
16
+
17
+ **An autonomous, AI-powered network troubleshooting agent for your terminal.**
18
+
19
+ NetDocAI is a Python-based CLI tool that investigates network connectivity problems using real diagnostic tools, autonomous reasoning, and retrieval-augmented generation (RAG).
20
+
21
+ Built with **LangGraph, Model Context Protocol (MCP), Google Gemini, and ChromaDB**, NetDocAI combines traditional network diagnostics with an AI agent capable of selecting tools, analyzing their results, forming hypotheses, and generating structured diagnostic reports.
22
+
23
+ Instead of manually running multiple networking commands and interpreting their outputs, users can describe their problem in natural language and let NetDocAI investigate.
24
+
25
+ ---
26
+
27
+ ## Features
28
+
29
+ - **Autonomous Troubleshooting:** Uses a LangGraph-based agent to plan, execute, and evaluate network diagnostics.
30
+ - **Natural Language Interface:** Describe networking problems directly in the terminal.
31
+ - **MCP Tool Integration:** Diagnostic utilities are exposed through a local Model Context Protocol server.
32
+ - **DNS Diagnostics:** Resolve domain names and inspect DNS resolution results.
33
+ - **Ping Diagnostics:** Check host reachability using ICMP.
34
+ - **TCP Connectivity Testing:** Test connectivity to specific hosts and ports.
35
+ - **HTTP Diagnostics:** Inspect HTTP responses and connection failures.
36
+ - **RAG-Powered Knowledge Retrieval:** Retrieve relevant information from bundled networking documentation.
37
+ - **Persistent Vector Database:** Store and retrieve knowledge embeddings using ChromaDB.
38
+ - **Gemini Integration:** Use Google Gemini for reasoning, tool selection, and knowledge embeddings.
39
+ - **First-Run API Key Setup:** Configure your own Gemini API key through an interactive onboarding interface.
40
+ - **Automatic Knowledge Indexing:** Initialize the knowledge base when retrieval is first requested.
41
+ - **Structured Diagnostic Reports:** Receive an organized summary of observations, retrieved knowledge, assessments, and conclusions.
42
+
43
+ ---
44
+
45
+ ## Installation
46
+
47
+ ### Requirements
48
+
49
+ - Python 3.11 or newer
50
+ - Internet connectivity for Gemini API requests
51
+ - A Google Gemini API key
52
+ - Network access for running diagnostics
53
+ - `pipx` (recommended for CLI installation)
54
+
55
+ NetDocAI executes its diagnostic tools locally. Internet connectivity is required for AI inference and for diagnostics involving external network resources.
56
+
57
+ ### Install from GitHub
58
+
59
+ NetDocAI can be installed directly from its GitHub repository using `pipx`:
60
+
61
+ ```bash
62
+ pipx install git+https://github.com/AbhiAnand-1011/NetDocAI.git
63
+ ```
64
+
65
+ Once installed, launch the application:
66
+
67
+ ```bash
68
+ netdocai
69
+ ```
70
+
71
+ ### Install from PyPI
72
+
73
+ After the first PyPI release, NetDocAI will also be available through:
74
+
75
+ ```bash
76
+ pipx install netdocai
77
+ ```
78
+
79
+ Alternatively, it can be installed using `pip` inside a Python virtual environment:
80
+
81
+ ```bash
82
+ pip install netdocai
83
+ ```
84
+
85
+ **Note:** PyPI distribution is being prepared. Until the package is published, use the GitHub installation method above.
86
+
87
+ ---
88
+
89
+ ## First-Time Setup
90
+
91
+ NetDocAI uses Google's Gemini API for autonomous reasoning, tool selection, and knowledge embeddings.
92
+
93
+ Each user must configure their own Gemini API key.
94
+
95
+ When launching NetDocAI for the first time:
96
+
97
+ ```bash
98
+ netdocai
99
+ ```
100
+
101
+ The CLI displays an onboarding interface containing a link to Google AI Studio.
102
+
103
+ **Get your Gemini API key:** https://aistudio.google.com/apikey
104
+
105
+ The application then prompts you to enter your API key.
106
+
107
+ NetDocAI attempts to validate the key before saving it. If Google's API is temporarily unavailable or rate-limited, the application allows you to decide whether to save the key without verification.
108
+
109
+ ### API Key Storage
110
+
111
+ On Linux, API keys entered during onboarding are stored locally at:
112
+
113
+ ```text
114
+ ~/.config/netdocai/api_key
115
+ ```
116
+
117
+ The application creates the configuration directory and restricts access to the credential file using filesystem permissions.
118
+
119
+ The key is stored as plaintext in a user-restricted file, not encrypted.
120
+
121
+ NetDocAI also supports reading an API key from the `GEMINI_API_KEY` environment variable or an existing `.env` configuration.
122
+
123
+ **You do not need to manually create a `.env` file when using the interactive onboarding system.**
124
+
125
+ The API key is used to communicate with Google's Gemini API. NetDocAI does not require an account on a separate NetDocAI service.
126
+
127
+ **Note:** The API key input is hidden for security. Characters will not appear while typing or pasting. Press Enter after entering your key.
128
+
129
+ ---
130
+
131
+ ## Usage
132
+
133
+ Start NetDocAI from your terminal:
134
+
135
+ ```bash
136
+ netdocai
137
+ ```
138
+
139
+ The CLI prompts you to describe your network problem.
140
+
141
+ For example:
142
+
143
+ ```text
144
+ Describe your network problem: google.com is not working
145
+ ```
146
+
147
+ Other example problems include:
148
+
149
+ ```text
150
+ I can ping google.com but cannot access it through HTTPS.
151
+ ```
152
+
153
+ ```text
154
+ My DNS resolution seems to be failing.
155
+ ```
156
+
157
+ ```text
158
+ I cannot establish a TCP connection to github.com on port 443.
159
+ ```
160
+
161
+ ```text
162
+ Some websites are reachable, but others keep timing out.
163
+ ```
164
+
165
+ NetDocAI determines which diagnostic tools to execute based on the problem and the evidence collected during the investigation.
166
+
167
+ The specific diagnostic sequence can vary between runs.
168
+
169
+ ### Diagnostic Workflow
170
+
171
+ During an investigation, NetDocAI may:
172
+
173
+ 1. Resolve domain names through DNS.
174
+ 2. Test host reachability using ICMP ping.
175
+ 3. Check TCP connectivity on relevant ports.
176
+ 4. Perform HTTP requests.
177
+ 5. Retrieve relevant networking documentation.
178
+ 6. Assess the collected evidence.
179
+ 7. Continue investigating or produce a final diagnostic report.
180
+
181
+ A simplified execution trace may look like:
182
+
183
+ ```text
184
+ NetDocAI
185
+ Autonomous Network Troubleshooter
186
+
187
+ Describe your network problem: google.com is not working
188
+
189
+ Investigating...
190
+
191
+ [Agent] dns
192
+ [Tool] Executing dns...
193
+ [Tool] dns completed.
194
+
195
+ [Agent] ping, tcp
196
+ [Tool] Executing ping...
197
+ [Tool] ping completed.
198
+ [Tool] Executing tcp...
199
+ [Tool] tcp completed.
200
+
201
+ [Agent] Finalizing diagnosis...
202
+ ```
203
+
204
+ Tool selection and execution depend on the agent's decisions and the reported problem.
205
+
206
+ ---
207
+
208
+ ## Architecture
209
+
210
+ NetDocAI combines a stateful LangGraph agent, Gemini reasoning, MCP diagnostic tools, and a local RAG knowledge base.
211
+
212
+ ```text
213
+ User
214
+ |
215
+ v
216
+ NetDocAI CLI
217
+ |
218
+ v
219
+ LangGraph Agent
220
+ |
221
+ v
222
+ Gemini Reasoning
223
+ |
224
+ +----------+----------+
225
+ | |
226
+ v v
227
+ MCP Server Agent Assessment
228
+ | |
229
+ +-------+-------+ |
230
+ | | | |
231
+ v v v |
232
+ DNS Ping TCP |
233
+ | | | |
234
+ +-------+-------+ |
235
+ | |
236
+ v |
237
+ HTTP |
238
+ | |
239
+ v |
240
+ search_docs |
241
+ | |
242
+ v |
243
+ ChromaDB |
244
+ | |
245
+ v |
246
+ Gemini Embeddings |
247
+ | |
248
+ +----------+----------+
249
+ |
250
+ v
251
+ Evidence Analysis
252
+ |
253
+ v
254
+ Diagnostic Report
255
+ ```
256
+
257
+ ### LangGraph Agent
258
+
259
+ The LangGraph agent maintains the investigation state, including:
260
+
261
+ - The original networking problem
262
+ - Conversation and tool-call history
263
+ - Available MCP tools
264
+ - Pending tool executions
265
+ - Collected observations
266
+ - Current diagnostic hypothesis
267
+ - Investigation progress
268
+ - Final response
269
+
270
+ The workflow consists of four primary nodes:
271
+
272
+ | Node | Responsibility |
273
+ |---|---|
274
+ | `plan` | Uses Gemini to reason about the problem and select tools |
275
+ | `execute_tools` | Executes selected MCP tools and records observations |
276
+ | `assess` | Evaluates diagnostic evidence and updates the hypothesis |
277
+ | `finalize` | Produces a report when the investigation reaches its configured step limit |
278
+
279
+ The agent can repeat the planning and assessment process until it reaches a conclusion or its diagnostic step limit.
280
+
281
+ ### Model Context Protocol (MCP)
282
+
283
+ NetDocAI uses MCP to expose its networking utilities to the agent.
284
+
285
+ The MCP server runs locally as a Python subprocess and communicates with the agent using standard input and output.
286
+
287
+ Five tools are currently available:
288
+
289
+ | Tool | Description |
290
+ |---|---|
291
+ | `ping` | Tests host reachability using ICMP |
292
+ | `dns` | Resolves a hostname to its IP addresses |
293
+ | `tcp` | Tests TCP connectivity to a specified host and port |
294
+ | `http` | Performs an HTTP request and returns response information |
295
+ | `search_docs` | Retrieves relevant networking documentation through RAG |
296
+
297
+ These tools perform actual diagnostic operations rather than simulated checks.
298
+
299
+ ### Retrieval-Augmented Generation (RAG)
300
+
301
+ NetDocAI includes a networking knowledge base used to support its diagnostic reasoning.
302
+
303
+ The retrieval pipeline consists of:
304
+
305
+ 1. Reading bundled Markdown documentation.
306
+ 2. Dividing the documents into text chunks.
307
+ 3. Generating embeddings using Google's Gemini embedding model.
308
+ 4. Storing the embeddings in ChromaDB.
309
+ 5. Performing semantic searches against the indexed documents.
310
+ 6. Returning relevant documentation to the agent through MCP.
311
+
312
+ The vector database is stored locally and reused between executions.
313
+
314
+ Knowledge indexing is triggered automatically when the RAG search tool is used and the collection is empty.
315
+
316
+ **Gemini API access is required for embedding generation.** Initial indexing may require multiple embedding requests.
317
+
318
+ ---
319
+
320
+ ## Knowledge Base
321
+
322
+ NetDocAI ships with networking documentation covering four areas:
323
+
324
+ | Document | Topic |
325
+ |---|---|
326
+ | `dns.md` | Domain Name System and name resolution |
327
+ | `tcp.md` | TCP connections and networking concepts |
328
+ | `http.md` | HTTP communication and related diagnostics |
329
+ | `linux_networking.md` | Linux networking fundamentals and troubleshooting |
330
+
331
+ The documents are bundled with the Python package.
332
+
333
+ Users do not need to download them separately or manually create the ChromaDB collection.
334
+
335
+ ### Local Database Storage
336
+
337
+ On Linux, the default ChromaDB storage location is:
338
+
339
+ ```text
340
+ ~/.local/share/netdocai/chroma_db/
341
+ ```
342
+
343
+ NetDocAI supports the `XDG_DATA_HOME` environment variable for configuring its application-data location.
344
+
345
+ The vector database persists across application launches.
346
+
347
+ ---
348
+
349
+ ## Diagnostic Reports
350
+
351
+ After an investigation, NetDocAI generates a structured report.
352
+
353
+ Reports contain the following sections:
354
+
355
+ | Section | Description |
356
+ |---|---|
357
+ | Problem | The original issue provided by the user |
358
+ | Network Observations | Results collected from diagnostic tools |
359
+ | Knowledge Retrieved | Sources retrieved from the networking knowledge base |
360
+ | Current Assessment | The agent's current hypothesis based on available evidence |
361
+ | Diagnosis | The final conclusion or investigation-limit message |
362
+
363
+ The report is displayed directly in the terminal using Rich.
364
+
365
+ Diagnoses are generated from the information available during execution and may not always identify the underlying problem conclusively.
366
+
367
+ ---
368
+
369
+ ## Tech Stack
370
+
371
+ | Technology | Purpose |
372
+ |---|---|
373
+ | Python | Application implementation |
374
+ | LangGraph | Stateful agent workflow and execution |
375
+ | Google Gemini API | AI reasoning and tool selection |
376
+ | Google Gen AI SDK | Gemini API integration |
377
+ | Model Context Protocol | Diagnostic tool communication |
378
+ | ChromaDB | Persistent vector storage and retrieval |
379
+ | Gemini Embeddings | Semantic embedding generation |
380
+ | Rich | Terminal interface and formatted output |
381
+ | setuptools | Python package building and distribution |
382
+
383
+ ---
384
+
385
+ ## Project Structure
386
+
387
+ ```text
388
+ NetDocAI/
389
+ |
390
+ ├── netdocai/
391
+ │ ├── __init__.py
392
+ │ ├── agent.py
393
+ │ ├── config.py
394
+ │ ├── gemini.py
395
+ │ ├── main.py
396
+ │ ├── mcp_server.py
397
+ │ ├── onboarding.py
398
+ │ ├── prompts.py
399
+ │ ├── rag.py
400
+ │ ├── report.py
401
+ │ ├── tools.py
402
+ │ │
403
+ │ └── knowledge/
404
+ │ ├── dns.md
405
+ │ ├── http.md
406
+ │ ├── linux_networking.md
407
+ │ └── tcp.md
408
+ │
409
+ ├── knowledge/
410
+ ├── .env.example
411
+ ├── .gitignore
412
+ ├── pyproject.toml
413
+ ├── requirements.txt
414
+ └── README.md
415
+ ```
416
+
417
+ ### Key Modules
418
+
419
+ - **`agent.py`** — LangGraph agent definition, planning, tool execution, and assessment.
420
+ - **`config.py`** — Gemini configuration and environment-based settings.
421
+ - **`gemini.py`** — Asynchronous Gemini API communication and retry handling.
422
+ - **`main.py`** — Rich-based terminal interface and CLI entry point.
423
+ - **`mcp_server.py`** — Local MCP server and registered diagnostic tools.
424
+ - **`onboarding.py`** — First-time API key configuration and validation.
425
+ - **`prompts.py`** — Agent instructions and prompt construction.
426
+ - **`rag.py`** — Knowledge indexing, embeddings, ChromaDB, and retrieval.
427
+ - **`report.py`** — Structured diagnostic report generation.
428
+ - **`tools.py`** — Network diagnostic implementations.
429
+
430
+ The packaged application uses the documentation inside `netdocai/knowledge/`.
431
+
432
+ ---
433
+
434
+ ## Development
435
+
436
+ ### Clone the Repository
437
+
438
+ ```bash
439
+ git clone https://github.com/AbhiAnand-1011/NetDocAI.git
440
+ cd NetDocAI
441
+ ```
442
+
443
+ ### Create a Virtual Environment
444
+
445
+ On Linux:
446
+
447
+ ```bash
448
+ python3 -m venv .venv
449
+ source .venv/bin/activate
450
+ ```
451
+
452
+ ### Install the Package in Editable Mode
453
+
454
+ ```bash
455
+ python -m pip install -e .
456
+ ```
457
+
458
+ ### Run NetDocAI
459
+
460
+ ```bash
461
+ netdocai
462
+ ```
463
+
464
+ The same first-time API key onboarding flow is available during development.
465
+
466
+ ### Build the Distribution
467
+
468
+ Install the Python build tool:
469
+
470
+ ```bash
471
+ python -m pip install build
472
+ ```
473
+
474
+ Build the source distribution and wheel:
475
+
476
+ ```bash
477
+ python -m build
478
+ ```
479
+
480
+ Generated distribution files are placed in the `dist/` directory.
481
+
482
+ The wheel includes the `netdocai` Python package and its bundled networking documentation.
483
+
484
+ ---
485
+
486
+ ## Configuration
487
+
488
+ NetDocAI supports the following environment variables:
489
+
490
+ | Variable | Purpose |
491
+ |---|---|
492
+ | `GEMINI_API_KEY` | Gemini API credential |
493
+ | `GEMINI_MODEL` | Override the configured Gemini reasoning model |
494
+ | `XDG_CONFIG_HOME` | Override the application configuration directory |
495
+ | `XDG_DATA_HOME` | Override the local application-data directory |
496
+
497
+ When no Gemini API key is available through the environment or previously saved configuration, NetDocAI launches its interactive onboarding flow.
498
+
499
+ Users are responsible for their own Gemini API usage and any applicable charges.
500
+
501
+ ---
502
+
503
+
504
+ ## Troubleshooting
505
+
506
+ ### Gemini API Key Not Configured
507
+
508
+ Launch NetDocAI:
509
+
510
+ ```bash
511
+ netdocai
512
+ ```
513
+
514
+ If no API key is found, the onboarding interface will request one.
515
+
516
+ Obtain a key from:
517
+
518
+ https://aistudio.google.com/apikey
519
+
520
+ ### Gemini API Rate Limit
521
+
522
+ If Gemini returns:
523
+
524
+ ```text
525
+ 429 RESOURCE_EXHAUSTED
526
+ ```
527
+
528
+ Your API project may have reached its applicable request quota.
529
+
530
+ Check your usage and rate limits through Google AI Studio.
531
+
532
+ ### Temporary Gemini API Failure
533
+
534
+ If Gemini returns:
535
+
536
+ ```text
537
+ 503 UNAVAILABLE
538
+ ```
539
+
540
+ The requested model may be temporarily unavailable or experiencing high demand.
541
+
542
+ NetDocAI includes retry handling for transient Gemini API failures.
543
+
544
+ ### First-Time Knowledge Indexing
545
+
546
+ The first RAG search may take longer because NetDocAI needs to generate embeddings and populate its local ChromaDB collection.
547
+
548
+ Subsequent searches reuse the stored index.
549
+
550
+ Indexing may fail if the Gemini embedding API is unavailable or its applicable quota is exhausted.
551
+
552
+ ---
553
+
554
+ ## Future Improvements
555
+
556
+ Potential future development areas include:
557
+
558
+ - Additional network diagnostic tools
559
+ - Support for multiple LLM providers
560
+ - More comprehensive networking documentation
561
+ - Improved error handling and retry strategies
562
+ - More flexible CLI arguments and configuration commands
563
+ - Improved cross-platform compatibility
564
+ - Expanded automated testing
565
+
566
+ These are planned possibilities rather than features currently implemented.
567
+
568
+ ---
569
+
570
+ ## Contributing
571
+
572
+ Contributions, issue reports, and suggestions are welcome.
573
+
574
+ To contribute:
575
+
576
+ 1. Fork the repository.
577
+ 2. Create a branch for your changes.
578
+ 3. Implement and test your modifications.
579
+ 4. Open a pull request describing your changes.
580
+
581
+ Bugs and feature requests can be submitted through the [GitHub Issues](https://github.com/AbhiAnand-1011/NetDocAI/issues) page.
582
+
583
+ ---
584
+
585
+