refactor: consolidate strict_mcp_config example into quick_start.py

- Remove separate strict_mcp_config_example.py file
- Add with_strict_mcp_config_example() to quick_start.py
- Use simpler query() function for consistency
- Add comment to main() about uncommenting MCP example if servers configured
This commit is contained in:
Lina Tawfik 2025-07-03 16:16:57 -07:00
parent 6a6991f48c
commit b73eac8c57
No known key found for this signature in database
2 changed files with 31 additions and 41 deletions

View file

@ -65,11 +65,42 @@ async def with_tools_example():
print()
async def with_strict_mcp_config_example():
"""Example using strict MCP configuration."""
print("=== Strict MCP Config Example ===")
# This ensures ONLY the MCP servers specified here will be used,
# ignoring any global or project-level MCP configurations
options = ClaudeCodeOptions(
mcp_servers={
"memory-server": {
"command": "npx",
"args": ["@modelcontextprotocol/server-memory"],
}
},
strict_mcp_config=True, # Ignore all file-based MCP configurations
)
async for message in query(
prompt="List the available MCP tools from the memory server",
options=options,
):
if isinstance(message, AssistantMessage):
for block in message.content:
if isinstance(block, TextBlock):
print(f"Claude: {block.text}")
elif isinstance(message, ResultMessage):
print(f"\nResult: {message.subtype}")
print()
async def main():
"""Run all examples."""
await basic_example()
await with_options_example()
await with_tools_example()
# Note: Uncomment the line below if you have MCP servers configured
# await with_strict_mcp_config_example()
if __name__ == "__main__":