mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
5e056b672e
* Python: Provider-leading client design & OpenAI package extraction Major refactoring of the Python Agent Framework client architecture: - Extract OpenAI clients into new `agent-framework-openai` package - Core package no longer depends on openai, azure-identity, azure-ai-projects - Rename clients for discoverability: OpenAIResponsesClient → OpenAIChatClient, OpenAIChatClient → OpenAIChatCompletionClient - Unify `model_id`/`deployment_name`/`model_deployment_name` → `model` param - New FoundryChatClient for Azure AI Foundry Responses API - New FoundryAgent/FoundryAgentClient for connecting to pre-configured Foundry agents - Remove OpenAIBase/OpenAIConfigMixin from non-deprecated client MRO - Deprecate AzureOpenAI* clients, AzureAIClient, OpenAIAssistantsClient - Reorganize samples: azure_openai+azure_ai+azure_ai_agent → azure/ - ADR-0020: Provider-Leading Client Design Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: missing Agent imports in samples, .model_id → .model in foundry_local sample Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: CI failures — mypy errors, coverage targets, sample imports - azure-ai mypy: add type ignores for TypedDict total=, model arg, forward ref - Coverage: replace core.azure/openai targets with openai package target - project_provider: add type annotation for opts dict Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: populate openai .pyi stub, fix broken README links, coverage targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fixes * updated observabilitty * reset azure init.pyi * fix errors * updated adr number * fix foundry local * fixed not renamed docstrings and comments, and added deprecated markers to old classes * fix tests and pyprojects * fix test vars * updated function tests * update durable * updated test setup for functions * Fix Foundry auth in workflow samples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Stabilize Python integration workflows Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update hosting samples for Foundry Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Trigger full CI rerun Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Trigger CI rerun again Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * trigger rerun * trigger rerun * fix for litellm * undo durabletask changes * Move Foundry APIs into foundry namespace Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Foundry pyproject formatting Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Split provider samples by Foundry surface Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Restore hosting sample requirements Also fix the Foundry Local sample link after the provider sample move. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * updated tests * udpated foundry integration tests * removed dist from azurefunctions tests * Use separate Foundry clients for concurrent agents Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix client setup in azfunc and durable * disabled two tests * updated setup for some function and durable tests * improved azure openai setup with new clients * ignore deprecated * fixes * skip 11 * remove openai assistants int tests --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
167 lines
5.1 KiB
YAML
167 lines
5.1 KiB
YAML
name: Setup Local MCP Server
|
|
description: Start and validate a local streamable HTTP MCP server for integration tests
|
|
|
|
inputs:
|
|
fallback_url:
|
|
description: Existing LOCAL_MCP_URL value to keep as a fallback if local startup fails
|
|
required: false
|
|
default: ''
|
|
host:
|
|
description: Host interface to bind the local MCP server
|
|
required: false
|
|
default: '127.0.0.1'
|
|
port:
|
|
description: Port to bind the local MCP server
|
|
required: false
|
|
default: '8011'
|
|
mount_path:
|
|
description: Mount path for the local streamable HTTP MCP endpoint
|
|
required: false
|
|
default: '/mcp'
|
|
|
|
outputs:
|
|
effective_url:
|
|
description: Local MCP URL when startup succeeds, otherwise the provided fallback URL
|
|
value: ${{ steps.start.outputs.effective_url }}
|
|
local_url:
|
|
description: URL of the local MCP server
|
|
value: ${{ steps.start.outputs.local_url }}
|
|
started:
|
|
description: Whether the local MCP server started and passed validation
|
|
value: ${{ steps.start.outputs.started }}
|
|
pid:
|
|
description: PID of the local MCP server process when startup succeeded
|
|
value: ${{ steps.start.outputs.pid }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Start and validate local MCP server
|
|
id: start
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
host="${{ inputs.host }}"
|
|
port="${{ inputs.port }}"
|
|
mount_path="${{ inputs.mount_path }}"
|
|
fallback_url="${{ inputs.fallback_url }}"
|
|
|
|
if [[ ! "$mount_path" =~ ^/ ]]; then
|
|
mount_path="/$mount_path"
|
|
fi
|
|
|
|
local_url="http://${host}:${port}${mount_path}"
|
|
health_url="http://${host}:${port}/healthz"
|
|
log_file="$RUNNER_TEMP/local-mcp-server.log"
|
|
pid_file="$RUNNER_TEMP/local-mcp-server.pid"
|
|
rm -f "$log_file" "$pid_file"
|
|
|
|
server_pid="$(
|
|
python3 - "$GITHUB_WORKSPACE/python" "$log_file" "$host" "$port" "$mount_path" <<'PY'
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
workspace, log_file, host, port, mount_path = sys.argv[1:]
|
|
|
|
with open(log_file, "w", encoding="utf-8") as log:
|
|
process = subprocess.Popen(
|
|
[
|
|
"uv",
|
|
"run",
|
|
"python",
|
|
"scripts/local_mcp_streamable_http_server.py",
|
|
"--host",
|
|
host,
|
|
"--port",
|
|
port,
|
|
"--mount-path",
|
|
mount_path,
|
|
],
|
|
cwd=workspace,
|
|
stdout=log,
|
|
stderr=subprocess.STDOUT,
|
|
start_new_session=True,
|
|
)
|
|
|
|
print(process.pid)
|
|
PY
|
|
)"
|
|
echo "$server_pid" > "$pid_file"
|
|
|
|
started=false
|
|
for _ in $(seq 1 30); do
|
|
if curl --silent --fail "$health_url" >/dev/null; then
|
|
started=true
|
|
break
|
|
fi
|
|
if ! kill -0 "$server_pid" 2>/dev/null; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
if [[ "$started" == "true" ]]; then
|
|
if ! (
|
|
cd "$GITHUB_WORKSPACE/python"
|
|
LOCAL_MCP_URL="$local_url" uv run python - <<'PY'
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from agent_framework import Content, MCPStreamableHTTPTool
|
|
|
|
|
|
def result_to_text(result: str | list[Content]) -> str:
|
|
if isinstance(result, str):
|
|
return result
|
|
return "\n".join(content.text for content in result if content.type == "text" and content.text)
|
|
|
|
|
|
async def main() -> None:
|
|
tool = MCPStreamableHTTPTool(
|
|
name="local_ci_mcp",
|
|
url=os.environ["LOCAL_MCP_URL"],
|
|
approval_mode="never_require",
|
|
)
|
|
|
|
async with tool:
|
|
assert tool.functions, "Local MCP server did not expose any tools."
|
|
result = result_to_text(await tool.functions[0].invoke(query="What is Agent Framework?"))
|
|
assert result, "Local MCP server returned an empty response."
|
|
|
|
|
|
asyncio.run(main())
|
|
PY
|
|
); then
|
|
started=false
|
|
fi
|
|
fi
|
|
|
|
effective_url="$local_url"
|
|
pid="$server_pid"
|
|
|
|
if [[ "$started" != "true" ]]; then
|
|
effective_url="$fallback_url"
|
|
pid=""
|
|
if kill -0 "$server_pid" 2>/dev/null; then
|
|
kill -TERM -- "-$server_pid" 2>/dev/null || kill -TERM "$server_pid" || true
|
|
sleep 1
|
|
kill -KILL -- "-$server_pid" 2>/dev/null || kill -KILL "$server_pid" || true
|
|
fi
|
|
echo "Local MCP server was unavailable; continuing with fallback LOCAL_MCP_URL."
|
|
if [[ -f "$log_file" ]]; then
|
|
tail -n 100 "$log_file" || true
|
|
fi
|
|
else
|
|
echo "Using local MCP server at $local_url"
|
|
fi
|
|
|
|
echo "started=$started" >> "$GITHUB_OUTPUT"
|
|
echo "local_url=$local_url" >> "$GITHUB_OUTPUT"
|
|
echo "effective_url=$effective_url" >> "$GITHUB_OUTPUT"
|
|
echo "pid=$pid" >> "$GITHUB_OUTPUT"
|