How to pass dynamic parameters (eg, index name, endpoint, key) from Semantic Kernel API to MCP server without involving LLM decision-making in enterprise production environment?

Kaja Sherief 115 Reputation points
2025-08-28T09:40:31.1466667+00:00

Problem Description:

I'm building a production-grade enterprise application using Semantic Kernel with Model Context Protocol (MCP) servers for vector search capabilities. I need to dynamically pass an Azure AI Search /Pinecone index name from my FastAPI service to the MCP server based on user requests, but I want this routing to be deterministic and not involve the LLM in the decision-making process.

Current Architecture:

  • API Layer: FastAPI service with Semantic Kernel ChatCompletionAgent
  • MCP Layer: FastMCP server handling Pinecone vector searches
  • Infrastructure: Azure OpenAI, Azure AI Search and Pinecone vector databases with multiple dbs and indexes

Current Implementation:

# API Side (semantic-kernel-client/main.py)
  @app.post("/chat", response_model=ChatResponse)
  async def chat_endpoint(
      request: ChatRequest,
      conversation_id: str = Depends(get_conversation_id),
      client_id: str = Depends(get_client_id),
      bot_id: str = Depends(get_bot_id)
  ):
      # How to pass index name to MCP without LLM involvement?
      result_item = await agent.get_response(
          messages=request.message,
          thread=channel.thread,
      )
  # MCP Server Side (common-mcp-server/main.py)
  @mcp.tool(structured_output=True)
  async def search_pinecone_tool(query: str, top_k: int = 5) -> str:     
      # Currently uses hardcoded index
      # Need dynamic index selection
      pinecone_index = _pinecone_client.Index("azure-docs-chat")

Requirements:

  • Enterprise-Grade: Must be production-ready, scalable, and maintainable
  • Deterministic: Index selection should not depend on LLM interpretation
  • Performance: Minimal latency overhead
  • Security: Support authorization and audit trails
  • Observability: Compatible with enterprise monitoring tools

What I've Considered:

  1. HTTP Headers Approach: Pass index name via request headers
  2. Service Registry Pattern: Create separate MCP connections per index
  3. URL Query Parameters: Append index to MCP server URL
  4. Session-Based Storage: Store index preference in session data

Specific Questions:

  1. What is the recommended Microsoft/enterprise pattern for passing context from Semantic Kernel to MCP servers in production environments?
  2. How can I modify the MCPStreamableHttpPlugin to dynamically pass parameters without involving the LLM in routing decisions?
  3. Is there a way to intercept and modify MCP requests before they reach the server to inject context headers?
  4. What's the best practice for managing multiple MCP connections with different configurations in a single Semantic Kernel application?
  5. Are there any built-in Semantic Kernel features for context passing to MCP servers that I might be missing?

Environment Details:

  • Semantic Kernel Version: Latest Python version with MCP support
  • Framework: FastAPI + Semantic Kernel + Azure OpenAI
  • MCP Implementation: FastMCP with Pinecone integration
  • Deployment: Azure Container Apps (planned)
  • Scale: Enterprise production with multiple concurrent users Any guidance on Microsoft's recommended patterns for this use case would be greatly appreciated!
Azure
Azure

A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.