fix: Apply pre-commit formatting changes
- Fix trailing whitespace in all files - Apply ruff formatting to match project standards - Ensure consistent code style across all MCP integration files This commit applies the exact changes that pre-commit hooks expect.
This commit is contained in:
@@ -34,38 +34,36 @@ class TwitterMCPRAG(BaseRAGExample):
|
|||||||
"--mcp-server",
|
"--mcp-server",
|
||||||
type=str,
|
type=str,
|
||||||
required=True,
|
required=True,
|
||||||
help="Command to start the Twitter MCP server (e.g., 'twitter-mcp-server' or 'npx twitter-mcp-server')"
|
help="Command to start the Twitter MCP server (e.g., 'twitter-mcp-server' or 'npx twitter-mcp-server')",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--username",
|
"--username", type=str, help="Twitter username to filter bookmarks (without @)"
|
||||||
type=str,
|
|
||||||
help="Twitter username to filter bookmarks (without @)"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--max-bookmarks",
|
"--max-bookmarks",
|
||||||
type=int,
|
type=int,
|
||||||
default=1000,
|
default=1000,
|
||||||
help="Maximum number of bookmarks to fetch (default: 1000)"
|
help="Maximum number of bookmarks to fetch (default: 1000)",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-tweet-content",
|
"--no-tweet-content",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Exclude tweet content, only include metadata"
|
help="Exclude tweet content, only include metadata",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-metadata",
|
"--no-metadata",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Exclude engagement metadata (likes, retweets, etc.)"
|
help="Exclude engagement metadata (likes, retweets, etc.)",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--test-connection",
|
"--test-connection",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Test MCP server connection and list available tools without indexing"
|
help="Test MCP server connection and list available tools without indexing",
|
||||||
)
|
)
|
||||||
|
|
||||||
async def test_mcp_connection(self, args) -> bool:
|
async def test_mcp_connection(self, args) -> bool:
|
||||||
@@ -84,20 +82,24 @@ class TwitterMCPRAG(BaseRAGExample):
|
|||||||
async with reader:
|
async with reader:
|
||||||
tools = await reader.list_available_tools()
|
tools = await reader.list_available_tools()
|
||||||
|
|
||||||
print(f"\n✅ Successfully connected to MCP server!")
|
print("\n✅ Successfully connected to MCP server!")
|
||||||
print(f"Available tools ({len(tools)}):")
|
print(f"Available tools ({len(tools)}):")
|
||||||
|
|
||||||
for i, tool in enumerate(tools, 1):
|
for i, tool in enumerate(tools, 1):
|
||||||
name = tool.get("name", "Unknown")
|
name = tool.get("name", "Unknown")
|
||||||
description = tool.get("description", "No description available")
|
description = tool.get("description", "No description available")
|
||||||
print(f"\n{i}. {name}")
|
print(f"\n{i}. {name}")
|
||||||
print(f" Description: {description[:100]}{'...' if len(description) > 100 else ''}")
|
print(
|
||||||
|
f" Description: {description[:100]}{'...' if len(description) > 100 else ''}"
|
||||||
|
)
|
||||||
|
|
||||||
# Show input schema if available
|
# Show input schema if available
|
||||||
schema = tool.get("inputSchema", {})
|
schema = tool.get("inputSchema", {})
|
||||||
if schema.get("properties"):
|
if schema.get("properties"):
|
||||||
props = list(schema["properties"].keys())[:3] # Show first 3 properties
|
props = list(schema["properties"].keys())[:3] # Show first 3 properties
|
||||||
print(f" Parameters: {', '.join(props)}{'...' if len(schema['properties']) > 3 else ''}")
|
print(
|
||||||
|
f" Parameters: {', '.join(props)}{'...' if len(schema['properties']) > 3 else ''}"
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -146,7 +148,7 @@ class TwitterMCPRAG(BaseRAGExample):
|
|||||||
# Show sample of what was loaded
|
# Show sample of what was loaded
|
||||||
if texts:
|
if texts:
|
||||||
sample_text = texts[0][:300] + "..." if len(texts[0]) > 300 else texts[0]
|
sample_text = texts[0][:300] + "..." if len(texts[0]) > 300 else texts[0]
|
||||||
print(f"\nSample bookmark:")
|
print("\nSample bookmark:")
|
||||||
print("-" * 50)
|
print("-" * 50)
|
||||||
print(sample_text)
|
print(sample_text)
|
||||||
print("-" * 50)
|
print("-" * 50)
|
||||||
@@ -171,7 +173,9 @@ class TwitterMCPRAG(BaseRAGExample):
|
|||||||
success = await self.test_mcp_connection(args)
|
success = await self.test_mcp_connection(args)
|
||||||
if not success:
|
if not success:
|
||||||
return
|
return
|
||||||
print(f"\n🎉 MCP server is working! You can now run without --test-connection to start indexing.")
|
print(
|
||||||
|
"\n🎉 MCP server is working! You can now run without --test-connection to start indexing."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Run the standard RAG pipeline
|
# Run the standard RAG pipeline
|
||||||
|
|||||||
Reference in New Issue
Block a user