nia-mcp-server 1.0.5__py3-none-any.whl → 1.0.7__py3-none-any.whl

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.

nia_mcp_server/server.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """
2
- NIA MCP Proxy Server - Lightweight server that communicates with NIA API
2
+ Nia MCP Proxy Server - Lightweight server that communicates with Nia API
3
3
  """
4
4
  import os
5
5
  import logging
@@ -12,6 +12,8 @@ from urllib.parse import urlparse
12
12
  from mcp.server.fastmcp import FastMCP
13
13
  from mcp.types import TextContent, Resource
14
14
  from .api_client import NIAApiClient, APIError
15
+ from .project_init import initialize_nia_project
16
+ from .profiles import get_supported_profiles
15
17
  from dotenv import load_dotenv
16
18
  import json
17
19
 
@@ -167,7 +169,26 @@ async def search_codebase(
167
169
  # Get all indexed repositories if not specified
168
170
  if not repositories:
169
171
  all_repos = await client.list_repositories()
170
- repositories = [repo["repository"] for repo in all_repos if repo.get("status") == "completed"]
172
+
173
+ # Ensure all_repos is a list and contains dictionaries
174
+ if not isinstance(all_repos, list):
175
+ logger.error(f"Unexpected type for all_repos: {type(all_repos)}")
176
+ return [TextContent(
177
+ type="text",
178
+ text="❌ Error retrieving repositories. The API returned an unexpected response."
179
+ )]
180
+
181
+ repositories = []
182
+ for repo in all_repos:
183
+ if isinstance(repo, dict) and repo.get("status") == "completed":
184
+ repo_name = repo.get("repository")
185
+ if repo_name:
186
+ repositories.append(repo_name)
187
+ else:
188
+ logger.warning(f"Repository missing 'repository' field: {repo}")
189
+ else:
190
+ logger.warning(f"Unexpected repository format: {type(repo)}, value: {repo}")
191
+
171
192
  if not repositories:
172
193
  return [TextContent(
173
194
  type="text",
@@ -364,7 +385,17 @@ async def list_repositories() -> List[TextContent]:
364
385
 
365
386
  for repo in repositories:
366
387
  status_icon = "✅" if repo.get("status") == "completed" else "⏳"
367
- lines.append(f"\n## {status_icon} {repo['repository']}")
388
+
389
+ # Show display name if available, otherwise show repository
390
+ display_name = repo.get("display_name")
391
+ repo_name = repo['repository']
392
+
393
+ if display_name:
394
+ lines.append(f"\n## {status_icon} {display_name}")
395
+ lines.append(f"- **Repository:** {repo_name}")
396
+ else:
397
+ lines.append(f"\n## {status_icon} {repo_name}")
398
+
368
399
  lines.append(f"- **Branch:** {repo.get('branch', 'main')}")
369
400
  lines.append(f"- **Status:** {repo.get('status', 'unknown')}")
370
401
  if repo.get("indexed_at"):
@@ -559,7 +590,17 @@ async def list_documentation() -> List[TextContent]:
559
590
 
560
591
  for source in sources:
561
592
  status_icon = "✅" if source.get("status") == "completed" else "⏳"
562
- lines.append(f"\n## {status_icon} {source.get('url', 'Unknown URL')}")
593
+
594
+ # Show display name if available, otherwise show URL
595
+ display_name = source.get("display_name")
596
+ url = source.get('url', 'Unknown URL')
597
+
598
+ if display_name:
599
+ lines.append(f"\n## {status_icon} {display_name}")
600
+ lines.append(f"- **URL:** {url}")
601
+ else:
602
+ lines.append(f"\n## {status_icon} {url}")
603
+
563
604
  lines.append(f"- **ID:** {source['id']}")
564
605
  lines.append(f"- **Status:** {source.get('status', 'unknown')}")
565
606
  lines.append(f"- **Type:** {source.get('source_type', 'web')}")
@@ -727,6 +768,100 @@ async def delete_repository(repository: str) -> List[TextContent]:
727
768
  text=f"❌ Error deleting repository: {str(e)}"
728
769
  )]
729
770
 
771
+ @mcp.tool()
772
+ async def rename_repository(repository: str, new_name: str) -> List[TextContent]:
773
+ """
774
+ Rename an indexed repository for better organization.
775
+
776
+ Args:
777
+ repository: Repository in owner/repo format
778
+ new_name: New display name for the repository (1-100 characters)
779
+
780
+ Returns:
781
+ Confirmation of rename operation
782
+ """
783
+ try:
784
+ # Validate name length
785
+ if not new_name or len(new_name) > 100:
786
+ return [TextContent(
787
+ type="text",
788
+ text="❌ Display name must be between 1 and 100 characters."
789
+ )]
790
+
791
+ client = await ensure_api_client()
792
+ result = await client.rename_repository(repository, new_name)
793
+
794
+ if result.get("success"):
795
+ return [TextContent(
796
+ type="text",
797
+ text=f"✅ Successfully renamed repository '{repository}' to '{new_name}'"
798
+ )]
799
+ else:
800
+ return [TextContent(
801
+ type="text",
802
+ text=f"❌ Failed to rename repository: {result.get('message', 'Unknown error')}"
803
+ )]
804
+
805
+ except APIError as e:
806
+ logger.error(f"API Error renaming repository: {e}")
807
+ error_msg = f"❌ {str(e)}"
808
+ if e.status_code == 403 and "lifetime limit" in str(e).lower():
809
+ error_msg += "\n\n💡 Tip: You've reached the free tier limit. Upgrade to Pro for unlimited access."
810
+ return [TextContent(type="text", text=error_msg)]
811
+ except Exception as e:
812
+ logger.error(f"Error renaming repository: {e}")
813
+ return [TextContent(
814
+ type="text",
815
+ text=f"❌ Error renaming repository: {str(e)}"
816
+ )]
817
+
818
+ @mcp.tool()
819
+ async def rename_documentation(source_id: str, new_name: str) -> List[TextContent]:
820
+ """
821
+ Rename a documentation source for better organization.
822
+
823
+ Args:
824
+ source_id: Documentation source ID
825
+ new_name: New display name for the documentation (1-100 characters)
826
+
827
+ Returns:
828
+ Confirmation of rename operation
829
+ """
830
+ try:
831
+ # Validate name length
832
+ if not new_name or len(new_name) > 100:
833
+ return [TextContent(
834
+ type="text",
835
+ text="❌ Display name must be between 1 and 100 characters."
836
+ )]
837
+
838
+ client = await ensure_api_client()
839
+ result = await client.rename_data_source(source_id, new_name)
840
+
841
+ if result.get("success"):
842
+ return [TextContent(
843
+ type="text",
844
+ text=f"✅ Successfully renamed documentation source to '{new_name}'"
845
+ )]
846
+ else:
847
+ return [TextContent(
848
+ type="text",
849
+ text=f"❌ Failed to rename documentation: {result.get('message', 'Unknown error')}"
850
+ )]
851
+
852
+ except APIError as e:
853
+ logger.error(f"API Error renaming documentation: {e}")
854
+ error_msg = f"❌ {str(e)}"
855
+ if e.status_code == 403 and "lifetime limit" in str(e).lower():
856
+ error_msg += "\n\n💡 Tip: You've reached the free tier limit. Upgrade to Pro for unlimited access."
857
+ return [TextContent(type="text", text=error_msg)]
858
+ except Exception as e:
859
+ logger.error(f"Error renaming documentation: {e}")
860
+ return [TextContent(
861
+ type="text",
862
+ text=f"❌ Error renaming documentation: {str(e)}"
863
+ )]
864
+
730
865
  @mcp.tool()
731
866
  async def nia_web_search(
732
867
  query: str,
@@ -781,7 +916,7 @@ async def nia_web_search(
781
916
  other_content = result.get("other_content", [])
782
917
 
783
918
  # Format response to naturally guide next actions
784
- response_text = f"## 🔍 NIA Web Search Results for: \"{query}\"\n\n"
919
+ response_text = f"## 🔍 Nia Web Search Results for: \"{query}\"\n\n"
785
920
 
786
921
  if days_back:
787
922
  response_text += f"*Showing results from the last {days_back} days*\n\n"
@@ -806,7 +941,7 @@ async def nia_web_search(
806
941
 
807
942
  # Be more aggressive based on query specificity
808
943
  if len(github_repos) == 1 or any(specific_word in query.lower() for specific_word in ["specific", "exact", "particular", "find me", "looking for"]):
809
- response_text += "**🚀 RECOMMENDED ACTION - Index this repository with NIA:**\n"
944
+ response_text += "**🚀 RECOMMENDED ACTION - Index this repository with Nia:**\n"
810
945
  response_text += f"```\nIndex {github_repos[0]['owner_repo']}\n```\n"
811
946
  response_text += "✨ This will enable AI-powered code search, understanding, and analysis!\n\n"
812
947
  else:
@@ -1075,6 +1210,162 @@ async def nia_deep_research_agent(
1075
1210
  "Try simplifying your question or using the regular nia_web_search tool."
1076
1211
  )]
1077
1212
 
1213
+ @mcp.tool()
1214
+ async def initialize_project(
1215
+ project_root: str,
1216
+ profiles: Optional[List[str]] = None
1217
+ ) -> List[TextContent]:
1218
+ """
1219
+ Initialize a NIA-enabled project with IDE-specific rules and configurations.
1220
+
1221
+ This tool sets up your project with NIA integration, creating configuration files
1222
+ and rules tailored to your IDE or editor. It enables AI assistants to better
1223
+ understand and work with NIA's knowledge search capabilities.
1224
+
1225
+ Args:
1226
+ project_root: Absolute path to the project root directory
1227
+ profiles: List of IDE profiles to set up (default: ["cursor"]).
1228
+ Options: cursor, vscode, claude, windsurf, cline, codex, zed, jetbrains, neovim, sublime
1229
+
1230
+ Returns:
1231
+ Status of the initialization with created files and next steps
1232
+
1233
+ Examples:
1234
+ - Basic: initialize_project("/path/to/project")
1235
+ - Multiple IDEs: initialize_project("/path/to/project", profiles=["cursor", "vscode"])
1236
+ - Specific IDE: initialize_project("/path/to/project", profiles=["windsurf"])
1237
+ """
1238
+ try:
1239
+ # Validate project root
1240
+ project_path = Path(project_root)
1241
+ if not project_path.is_absolute():
1242
+ return [TextContent(
1243
+ type="text",
1244
+ text=f"❌ Error: project_root must be an absolute path. Got: {project_root}"
1245
+ )]
1246
+
1247
+ # Default to cursor profile if none specified
1248
+ if profiles is None:
1249
+ profiles = ["cursor"]
1250
+
1251
+ # Validate profiles
1252
+ supported = get_supported_profiles()
1253
+ invalid_profiles = [p for p in profiles if p not in supported]
1254
+ if invalid_profiles:
1255
+ return [TextContent(
1256
+ type="text",
1257
+ text=f"❌ Unknown profiles: {', '.join(invalid_profiles)}\n\n"
1258
+ f"Supported profiles: {', '.join(supported)}"
1259
+ )]
1260
+
1261
+ logger.info(f"Initializing NIA project at {project_root} with profiles: {profiles}")
1262
+
1263
+ # Initialize the project
1264
+ result = initialize_nia_project(
1265
+ project_root=project_root,
1266
+ profiles=profiles
1267
+ )
1268
+
1269
+ if not result.get("success"):
1270
+ return [TextContent(
1271
+ type="text",
1272
+ text=f"❌ Failed to initialize project: {result.get('error', 'Unknown error')}"
1273
+ )]
1274
+
1275
+ # Format success response
1276
+ response_lines = [
1277
+ f"✅ Successfully initialized NIA project at: {project_root}",
1278
+ "",
1279
+ "## 📁 Created Files:",
1280
+ ]
1281
+
1282
+ for file in result.get("files_created", []):
1283
+ response_lines.append(f"- {file}")
1284
+
1285
+ if result.get("profiles_initialized"):
1286
+ response_lines.extend([
1287
+ "",
1288
+ "## 🎨 Initialized Profiles:",
1289
+ ])
1290
+ for profile in result["profiles_initialized"]:
1291
+ response_lines.append(f"- {profile}")
1292
+
1293
+ if result.get("warnings"):
1294
+ response_lines.extend([
1295
+ "",
1296
+ "## ⚠️ Warnings:",
1297
+ ])
1298
+ for warning in result["warnings"]:
1299
+ response_lines.append(f"- {warning}")
1300
+
1301
+ if result.get("next_steps"):
1302
+ response_lines.extend([
1303
+ "",
1304
+ "## 🚀 Next Steps:",
1305
+ ])
1306
+ for i, step in enumerate(result["next_steps"], 1):
1307
+ response_lines.append(f"{i}. {step}")
1308
+
1309
+ # Add profile-specific instructions
1310
+ response_lines.extend([
1311
+ "",
1312
+ "## 💡 Quick Start:",
1313
+ ])
1314
+
1315
+ if "cursor" in profiles:
1316
+ response_lines.extend([
1317
+ "**For Cursor:**",
1318
+ "1. Restart Cursor to load the NIA MCP server",
1319
+ "2. Run `list_repositories` to verify connection",
1320
+ "3. Start indexing with `index_repository https://github.com/owner/repo`",
1321
+ ""
1322
+ ])
1323
+
1324
+ if "vscode" in profiles:
1325
+ response_lines.extend([
1326
+ "**For VSCode:**",
1327
+ "1. Reload the VSCode window (Cmd/Ctrl+R)",
1328
+ "2. Open command palette (Cmd/Ctrl+Shift+P)",
1329
+ "3. Run 'NIA: Index Repository' task",
1330
+ ""
1331
+ ])
1332
+
1333
+ if "claude" in profiles:
1334
+ response_lines.extend([
1335
+ "**For Claude Desktop:**",
1336
+ "1. The .claude directory has been created",
1337
+ "2. Claude will now understand NIA commands",
1338
+ "3. Try: 'Search for authentication patterns'",
1339
+ ""
1340
+ ])
1341
+
1342
+ # Add general tips
1343
+ response_lines.extend([
1344
+ "## 📚 Tips:",
1345
+ "- Use natural language for searches: 'How does X work?'",
1346
+ "- Index repositories before searching them",
1347
+ "- Use `nia_web_search` to discover new repositories",
1348
+ "- Check `list_repositories` to see what's already indexed",
1349
+ "",
1350
+ "Ready to supercharge your development with AI-powered code search! 🚀"
1351
+ ])
1352
+
1353
+ return [TextContent(
1354
+ type="text",
1355
+ text="\n".join(response_lines)
1356
+ )]
1357
+
1358
+ except Exception as e:
1359
+ logger.error(f"Error in initialize_project tool: {e}")
1360
+ return [TextContent(
1361
+ type="text",
1362
+ text=f"❌ Error initializing project: {str(e)}\n\n"
1363
+ "Please check:\n"
1364
+ "- The project_root path is correct and accessible\n"
1365
+ "- You have write permissions to the directory\n"
1366
+ "- The NIA MCP server is properly installed"
1367
+ )]
1368
+
1078
1369
  # Resources
1079
1370
 
1080
1371
  # Note: FastMCP doesn't have list_resources or read_resource decorators
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nia-mcp-server
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: NIA Knowledge Agent - MCP server for intelligent codebase search
5
5
  Project-URL: Homepage, https://trynia.ai
6
6
  Project-URL: Documentation, https://docs.trynia.ai
@@ -0,0 +1,17 @@
1
+ nia_mcp_server/__init__.py,sha256=Q-MLB7q1vWZ-UKUj8MzVk2mtiydn9wTsFtQ7kicpOyo,84
2
+ nia_mcp_server/__main__.py,sha256=XY11ESL4hctu-BBgtPATFZyd1o-O7wE7y-UOSoNs-hw,152
3
+ nia_mcp_server/api_client.py,sha256=dk9FkMljuekyjIw7Ij3athsoVNnu7E2b1l2xi2XtB1Y,24255
4
+ nia_mcp_server/profiles.py,sha256=2DD8PFRr5Ij4IK4sPUz0mH8aKjkrEtkKLC1R0iki2bA,7221
5
+ nia_mcp_server/project_init.py,sha256=T0-ziJhofL4L8APwnM43BLhxtlmOHaYH-V9PF2yXLw4,7138
6
+ nia_mcp_server/rule_transformer.py,sha256=wCxoQ1Kl_rI9mUFnh9kG5iCXYU4QInrmFQOReZfAFVo,11000
7
+ nia_mcp_server/server.py,sha256=B6aLTXkX2Mq5eBqDCV_WTumqtSm4bzDf2bHPVyVsgcA,59579
8
+ nia_mcp_server/assets/rules/claude_rules.md,sha256=HNL5GJMUbFxSpNbIAJUQWqAywjMl4lf530I1in69aNY,7380
9
+ nia_mcp_server/assets/rules/cursor_rules.md,sha256=hd6lhzNrK1ULQUYIEVeOnyKnuLKq4hmwZPbMqGUI1Lk,1720
10
+ nia_mcp_server/assets/rules/nia_rules.md,sha256=mvdYrkoiRgxeROhtnRXCV53TX5B9wqLiCJ6oYTqSPfY,6345
11
+ nia_mcp_server/assets/rules/vscode_rules.md,sha256=fqn4aJO_bhftaCGkVoquruQHf3EaREQJQWHXq6a4FOk,6967
12
+ nia_mcp_server/assets/rules/windsurf_rules.md,sha256=PzU2as5gaiVsV6PAzg8T_-GR7VCyRQGMjAHcSzYF_ms,3354
13
+ nia_mcp_server-1.0.7.dist-info/METADATA,sha256=mbOODzDtkXWQV9tXdYY2lVc5XrkarBsM1genV3dl3Jw,6910
14
+ nia_mcp_server-1.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ nia_mcp_server-1.0.7.dist-info/entry_points.txt,sha256=V74FQEp48pfWxPCl7B9mihtqvIJNVjCSbRfCz4ww77I,64
16
+ nia_mcp_server-1.0.7.dist-info/licenses/LICENSE,sha256=5jUPBVkZEicxSAZ91jOO7i8zXEPAHS6M0w8SSf6DftI,1071
17
+ nia_mcp_server-1.0.7.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- nia_mcp_server/__init__.py,sha256=P3fqcVlJ9fp8ojx6xaX5lrdUNO8rkc8bGYEv8Qm3SAw,84
2
- nia_mcp_server/__main__.py,sha256=XY11ESL4hctu-BBgtPATFZyd1o-O7wE7y-UOSoNs-hw,152
3
- nia_mcp_server/api_client.py,sha256=E7x6W2zvFrfyR8yfk8X4z6WGF6wQk_EP4TfQhZAV_4w,20932
4
- nia_mcp_server/server.py,sha256=UJaP4Q7xlZt_xW4bDD17AgYhwAZ2sZaoTZ6nf_2mNOE,48694
5
- nia_mcp_server-1.0.5.dist-info/METADATA,sha256=lyWMV-006_5q1vb_aEnHWwUE8lAYcZMpbL9ypEi5kiI,6910
6
- nia_mcp_server-1.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- nia_mcp_server-1.0.5.dist-info/entry_points.txt,sha256=V74FQEp48pfWxPCl7B9mihtqvIJNVjCSbRfCz4ww77I,64
8
- nia_mcp_server-1.0.5.dist-info/licenses/LICENSE,sha256=5jUPBVkZEicxSAZ91jOO7i8zXEPAHS6M0w8SSf6DftI,1071
9
- nia_mcp_server-1.0.5.dist-info/RECORD,,