nia-mcp-server 1.0.7__tar.gz → 1.0.8__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.

Potentially problematic release.


This version of nia-mcp-server might be problematic. Click here for more details.

Files changed (21) hide show
  1. nia_mcp_server-1.0.8/LICENSE +31 -0
  2. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/PKG-INFO +6 -8
  3. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/README.md +1 -1
  4. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/pyproject.toml +7 -9
  5. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/__init__.py +1 -1
  6. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/api_client.py +4 -2
  7. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/server.py +159 -0
  8. nia_mcp_server-1.0.7/LICENSE +0 -21
  9. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/.gitignore +0 -0
  10. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/ARCHITECTURE.md +0 -0
  11. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/nia_analytics.log +0 -0
  12. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/nia_mcp_server.log +0 -0
  13. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/__main__.py +0 -0
  14. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/assets/rules/claude_rules.md +0 -0
  15. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/assets/rules/cursor_rules.md +0 -0
  16. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/assets/rules/nia_rules.md +0 -0
  17. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/assets/rules/vscode_rules.md +0 -0
  18. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/assets/rules/windsurf_rules.md +0 -0
  19. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/profiles.py +0 -0
  20. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/project_init.py +0 -0
  21. {nia_mcp_server-1.0.7 → nia_mcp_server-1.0.8}/src/nia_mcp_server/rule_transformer.py +0 -0
@@ -0,0 +1,31 @@
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2024 NIA (trynia.ai)
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+
19
+ Additional permissions under GNU AGPL version 3 section 7:
20
+
21
+ If you modify this Program, or any covered work, by linking or combining it
22
+ with other code, such other code is not for that reason alone subject to any
23
+ of the requirements of the GNU Affero General Public License.
24
+
25
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
26
+ EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
27
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
28
+ IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29
+ AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
30
+ PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
31
+ YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
@@ -1,18 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nia-mcp-server
3
- Version: 1.0.7
4
- Summary: NIA Knowledge Agent - MCP server for intelligent codebase search
3
+ Version: 1.0.8
4
+ Summary: Nia Knowledge Agent
5
5
  Project-URL: Homepage, https://trynia.ai
6
6
  Project-URL: Documentation, https://docs.trynia.ai
7
- Project-URL: Repository, https://github.com/trynia/nia-mcp-server
8
- Project-URL: Issues, https://github.com/trynia/nia-mcp-server/issues
9
- Author-email: NIA Team <support@trynia.ai>
10
- License-Expression: MIT
7
+ Author-email: Nia Team <founders@nozomio.com>
8
+ License-Expression: AGPL-3.0
11
9
  License-File: LICENSE
12
10
  Keywords: ai,codebase,mcp,nia,search
13
11
  Classifier: Development Status :: 4 - Beta
14
12
  Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
16
14
  Classifier: Programming Language :: Python :: 3
17
15
  Classifier: Programming Language :: Python :: 3.8
18
16
  Classifier: Programming Language :: Python :: 3.9
@@ -203,7 +201,7 @@ Add to your Cline settings:
203
201
  ## Environment Variables
204
202
 
205
203
  - `NIA_API_KEY` (required) - Your NIA API key
206
- - `NIA_API_URL` (optional) - API endpoint (defaults to https://api.trynia.ai)
204
+ - `NIA_API_URL` (optional) - API endpoint (defaults to https://apigcp.trynia.ai)
207
205
 
208
206
  ## Pricing
209
207
 
@@ -175,7 +175,7 @@ Add to your Cline settings:
175
175
  ## Environment Variables
176
176
 
177
177
  - `NIA_API_KEY` (required) - Your NIA API key
178
- - `NIA_API_URL` (optional) - API endpoint (defaults to https://api.trynia.ai)
178
+ - `NIA_API_URL` (optional) - API endpoint (defaults to https://apigcp.trynia.ai)
179
179
 
180
180
  ## Pricing
181
181
 
@@ -4,19 +4,19 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nia-mcp-server"
7
- version = "1.0.7"
8
- description = "NIA Knowledge Agent - MCP server for intelligent codebase search"
7
+ version = "1.0.8"
8
+ description = "Nia Knowledge Agent"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
11
- license = "MIT"
11
+ license = "AGPL-3.0"
12
12
  authors = [
13
- { name = "NIA Team", email = "support@trynia.ai" }
13
+ { name = "Nia Team", email = "founders@nozomio.com" }
14
14
  ]
15
15
  keywords = ["mcp", "ai", "codebase", "search", "nia"]
16
16
  classifiers = [
17
17
  "Development Status :: 4 - Beta",
18
18
  "Intended Audience :: Developers",
19
- "License :: OSI Approved :: MIT License",
19
+ "License :: OSI Approved :: GNU Affero General Public License v3",
20
20
  "Programming Language :: Python :: 3",
21
21
  "Programming Language :: Python :: 3.8",
22
22
  "Programming Language :: Python :: 3.9",
@@ -35,11 +35,9 @@ dependencies = [
35
35
  [project.urls]
36
36
  Homepage = "https://trynia.ai"
37
37
  Documentation = "https://docs.trynia.ai"
38
- Repository = "https://github.com/trynia/nia-mcp-server"
39
- Issues = "https://github.com/trynia/nia-mcp-server/issues"
40
38
 
41
- [project.scripts]
42
- nia-mcp-server = "nia_mcp_server.__main__:main"
39
+
40
+
43
41
 
44
42
  [tool.hatch.build.targets.wheel]
45
43
  packages = ["src/nia_mcp_server"]
@@ -2,4 +2,4 @@
2
2
  NIA MCP Server - Proxy server for NIA Knowledge Agent
3
3
  """
4
4
 
5
- __version__ = "1.0.7"
5
+ __version__ = "1.0.8"
@@ -24,7 +24,7 @@ class NIAApiClient:
24
24
  def __init__(self, api_key: str, base_url: str = None):
25
25
  self.api_key = api_key
26
26
  # Remove trailing slash from base URL to prevent double slashes
27
- self.base_url = (base_url or os.getenv("NIA_API_URL", "https://api.trynia.ai")).rstrip('/')
27
+ self.base_url = (base_url or os.getenv("NIA_API_URL", "https://apigcp.trynia.ai")).rstrip('/')
28
28
  self.client = httpx.AsyncClient(
29
29
  headers={
30
30
  "Authorization": f"Bearer {api_key}",
@@ -400,6 +400,7 @@ class NIAApiClient:
400
400
  self,
401
401
  url: str,
402
402
  url_patterns: List[str] = None,
403
+ exclude_patterns: List[str] = None,
403
404
  max_age: int = None,
404
405
  only_main_content: bool = True
405
406
  ) -> Dict[str, Any]:
@@ -407,7 +408,8 @@ class NIAApiClient:
407
408
  try:
408
409
  payload = {
409
410
  "url": url,
410
- "url_patterns": url_patterns or []
411
+ "url_patterns": url_patterns or [],
412
+ "exclude_patterns": exclude_patterns or []
411
413
  }
412
414
 
413
415
  # Add optional parameters
@@ -5,6 +5,7 @@ import os
5
5
  import logging
6
6
  import json
7
7
  import asyncio
8
+ import webbrowser
8
9
  from typing import List, Optional, Dict, Any
9
10
  from datetime import datetime
10
11
  from urllib.parse import urlparse
@@ -503,6 +504,7 @@ async def check_repository_status(repository: str) -> List[TextContent]:
503
504
  async def index_documentation(
504
505
  url: str,
505
506
  url_patterns: Optional[List[str]] = None,
507
+ exclude_patterns: Optional[List[str]] = None,
506
508
  max_age: Optional[int] = None,
507
509
  only_main_content: Optional[bool] = True
508
510
  ) -> List[TextContent]:
@@ -512,6 +514,7 @@ async def index_documentation(
512
514
  Args:
513
515
  url: URL of the documentation site to index
514
516
  url_patterns: Optional list of URL patterns to include in crawling (e.g., ["/docs/*", "/guide/*"])
517
+ exclude_patterns: Optional list of URL patterns to exclude from crawling (e.g., ["/blog/*", "/changelog/*"])
515
518
  max_age: Maximum age of cached content in seconds (for fast scraping mode)
516
519
  only_main_content: Extract only main content (removes navigation, ads, etc.)
517
520
 
@@ -520,6 +523,8 @@ async def index_documentation(
520
523
 
521
524
  Important:
522
525
  - When started indexing, prompt users to either use check_documentation_status tool or go to app.trynia.ai to check the status.
526
+ - By default, crawls the entire domain (up to 10,000 pages)
527
+ - Use exclude_patterns to filter out unwanted sections like blogs, changelogs, etc.
523
528
  """
524
529
  try:
525
530
  client = await ensure_api_client()
@@ -529,6 +534,7 @@ async def index_documentation(
529
534
  result = await client.create_data_source(
530
535
  url=url,
531
536
  url_patterns=url_patterns,
537
+ exclude_patterns=exclude_patterns,
532
538
  max_age=max_age,
533
539
  only_main_content=only_main_content
534
540
  )
@@ -1366,6 +1372,159 @@ async def initialize_project(
1366
1372
  "- The NIA MCP server is properly installed"
1367
1373
  )]
1368
1374
 
1375
+ @mcp.tool()
1376
+ async def visualize_codebase(
1377
+ repository: str
1378
+ ) -> List[TextContent]:
1379
+ """
1380
+ Open the graph visualization for an indexed repository in a browser.
1381
+
1382
+ This tool launches a browser with the interactive graph visualization
1383
+ that shows the code structure, relationships, and dependencies of
1384
+ the indexed codebase.
1385
+
1386
+ Args:
1387
+ repository: Repository in owner/repo format (e.g., "facebook/react")
1388
+
1389
+ Returns:
1390
+ Status message with the URL that was opened
1391
+
1392
+ Examples:
1393
+ - visualize_codebase("facebook/react")
1394
+ - visualize_codebase("langchain-ai/langchain")
1395
+ """
1396
+ try:
1397
+ client = await ensure_api_client()
1398
+
1399
+ logger.info(f"Looking up repository: {repository}")
1400
+
1401
+ # List all repositories to find the matching one
1402
+ repositories = await client.list_repositories()
1403
+
1404
+ # Find the repository by name
1405
+ matching_repo = None
1406
+ for repo in repositories:
1407
+ if repo.get("repository") == repository:
1408
+ matching_repo = repo
1409
+ break
1410
+
1411
+ if not matching_repo:
1412
+ # Try case-insensitive match as fallback
1413
+ repository_lower = repository.lower()
1414
+ for repo in repositories:
1415
+ if repo.get("repository", "").lower() == repository_lower:
1416
+ matching_repo = repo
1417
+ break
1418
+
1419
+ if not matching_repo:
1420
+ return [TextContent(
1421
+ type="text",
1422
+ text=f"❌ Repository '{repository}' not found.\n\n"
1423
+ f"Available repositories:\n" +
1424
+ "\n".join(f"- {r.get('repository')}" for r in repositories if r.get('repository')) +
1425
+ "\n\nUse `list_repositories` to see all indexed repositories."
1426
+ )]
1427
+
1428
+ # Check if the repository is fully indexed
1429
+ status = matching_repo.get("status", "unknown")
1430
+ # Use the actual project ID if available, fall back to repository_id
1431
+ repository_id = matching_repo.get("id") or matching_repo.get("repository_id")
1432
+
1433
+ if not repository_id:
1434
+ return [TextContent(
1435
+ type="text",
1436
+ text=f"❌ No repository ID found for '{repository}'. This may be a data inconsistency."
1437
+ )]
1438
+
1439
+ if status != "completed":
1440
+ warning_msg = f"⚠️ Note: Repository '{repository}' is currently {status}.\n"
1441
+ if status == "indexing":
1442
+ warning_msg += "The visualization may show incomplete data.\n\n"
1443
+ elif status == "error":
1444
+ error_msg = matching_repo.get("error", "Unknown error")
1445
+ warning_msg += f"Error: {error_msg}\n\n"
1446
+ else:
1447
+ warning_msg += "The visualization may not be available.\n\n"
1448
+ else:
1449
+ warning_msg = ""
1450
+
1451
+ # Determine the base URL based on the API URL
1452
+ api_base_url = client.base_url
1453
+ if "localhost" in api_base_url or "127.0.0.1" in api_base_url:
1454
+ # Local development
1455
+ app_base_url = "http://localhost:3000"
1456
+ else:
1457
+ # Production
1458
+ app_base_url = "https://app.trynia.ai"
1459
+
1460
+ # Construct the visualization URL
1461
+ visualization_url = f"{app_base_url}/visualize/{repository_id}"
1462
+
1463
+ # Try to open the browser
1464
+ try:
1465
+ webbrowser.open(visualization_url)
1466
+ browser_opened = True
1467
+ open_msg = "✅ Opening graph visualization in your default browser..."
1468
+ except Exception as e:
1469
+ logger.warning(f"Failed to open browser: {e}")
1470
+ browser_opened = False
1471
+ open_msg = "⚠️ Could not automatically open browser."
1472
+
1473
+ # Format the response
1474
+ response_lines = [
1475
+ f"# Graph Visualization: {repository}",
1476
+ "",
1477
+ warning_msg if warning_msg else "",
1478
+ open_msg,
1479
+ "",
1480
+ f"**URL:** {visualization_url}",
1481
+ "",
1482
+ ]
1483
+
1484
+ if matching_repo.get("display_name"):
1485
+ response_lines.append(f"**Display Name:** {matching_repo['display_name']}")
1486
+
1487
+ response_lines.extend([
1488
+ f"**Branch:** {matching_repo.get('branch', 'main')}",
1489
+ f"**Status:** {status}",
1490
+ "",
1491
+ "## Features Available:",
1492
+ "- 🔍 Interactive force-directed graph",
1493
+ "- 🎨 Color-coded node types (functions, classes, files, etc.)",
1494
+ "- 🔗 Relationship visualization (calls, imports, inherits, etc.)",
1495
+ "- 💬 Click on any node to chat with that specific code element",
1496
+ "- 🔎 Search and filter capabilities",
1497
+ "- 📊 Graph statistics and insights"
1498
+ ])
1499
+
1500
+ if not browser_opened:
1501
+ response_lines.extend([
1502
+ "",
1503
+ "**Manual Access:**",
1504
+ f"Copy and paste this URL into your browser: {visualization_url}"
1505
+ ])
1506
+
1507
+ return [TextContent(
1508
+ type="text",
1509
+ text="\n".join(response_lines)
1510
+ )]
1511
+
1512
+ except APIError as e:
1513
+ logger.error(f"API Error in visualize_codebase: {e}")
1514
+ if e.status_code == 403 or "free tier limit" in str(e).lower():
1515
+ return [TextContent(
1516
+ type="text",
1517
+ text=f"❌ {str(e)}\n\n💡 Tip: Upgrade to Pro at https://trynia.ai/billing for unlimited access."
1518
+ )]
1519
+ else:
1520
+ return [TextContent(type="text", text=f"❌ {str(e)}")]
1521
+ except Exception as e:
1522
+ logger.error(f"Error in visualize_codebase: {e}")
1523
+ return [TextContent(
1524
+ type="text",
1525
+ text=f"❌ Error opening visualization: {str(e)}"
1526
+ )]
1527
+
1369
1528
  # Resources
1370
1529
 
1371
1530
  # Note: FastMCP doesn't have list_resources or read_resource decorators
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 NIA (trynia.ai)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.