paulyuk/simple-serverless-agent-python-aigateway

Serverless Azure Functions timer port of the Foundry Hosted Agent daily repo digest sample, routed through AI Gateway. Community concept.

★ 0Forks 0PythonGitHub ↗Compare

README

Serverless Repo Digest Agent (AI Gateway)

This is a community concept port of the Foundry Hosted Agent sample Azure-Samples/simple-foundry-hosted-agent-python-aigateway to the Azure Functions serverless agents runtime. It uses the same daily-repo-digest agent and AI Gateway routing, but the trigger is an Azure Functions Timer with schedule 0 0 8 * * * instead of an interactive host. The core agent code is reused from repo_digest_agent.py.

How the port works

The Foundry Hosted Agent main.py, a ResponsesHostServer, is replaced by functions_app.py, an Azure Functions Timer trigger plus an optional HTTP trigger for on-demand testing. The agent logic follows the Foundry Hosted Agent sample, with an added standalone GitHub MCP path for Azure Functions hosting.

Prerequisites

  • Python 3.11+ for Azure Functions Python
  • Azure Functions Core Tools v4
  • An AI Gateway endpoint and key
  • A GitHub token for the GitHub MCP server
  • az and func CLIs

Run locally

  1. Copy the example settings file:

    cp local.settings.json.example local.settings.json
  2. Fill in your AI Gateway, GitHub token, and repository values in local.settings.json.

  3. Install dependencies:

    pip install -r requirements.txt
  4. Start the Functions host:

    func start
  5. Invoke the optional HTTP trigger:

    curl "http://localhost:7071/api/digest"

GitHub tools via MCP

The original Foundry Hosted Agent sample gets GitHub tools from Foundry Toolbox. In that setup, the aigw-github MCP connection is provisioned by the sample infrastructure and routed through AI Gateway, which requires Foundry hosting and its azd up resources.

This serverless port can run outside Foundry hosting by connecting directly to a GitHub MCP server. By default it uses the hosted GitHub MCP endpoint https://api.githubcopilot.com/mcp/ and sends GITHUB_TOKEN as a bearer token. You can point GITHUB_MCP_URL at another streamable HTTP MCP endpoint, such as a self-hosted github-mcp-server.

When FOUNDRY_HOSTING_ENVIRONMENT is set, the agent keeps the Foundry Toolbox path for users who do run it inside Foundry hosting.

A full end-to-end run still requires your own working AI Gateway endpoint and key through AZURE_AI_GATEWAY_ENDPOINT and AZURE_AI_GATEWAY_API_KEY, plus a GitHub token with access to the target repository. This repository is a concept that you configure with your own credentials. It is not verified working with your resources by default.

Configuration

Setting Description
AzureWebJobsStorage Storage connection used by the Functions host and Timer trigger monitor. The example uses local development storage.
FUNCTIONS_WORKER_RUNTIME Azure Functions worker runtime. Set to python.
AZURE_AI_GATEWAY_ENDPOINT Your AI Gateway endpoint URL.
AZURE_AI_GATEWAY_API_KEY Your AI Gateway API key. Do not commit real keys.
AZURE_AI_GATEWAY_MODEL Model deployment or model name routed through AI Gateway. The example uses gpt-latest.
GITHUB_REPOSITORY Repository to summarize. The example default is microsoft/agent-framework.
GITHUB_TOKEN GitHub token sent to the GitHub MCP server as a bearer token. Do not commit real tokens.
GITHUB_PERSONAL_ACCESS_TOKEN Optional fallback token variable if GITHUB_TOKEN is not set.
GITHUB_MCP_URL Streamable HTTP GitHub MCP endpoint. Defaults to https://api.githubcopilot.com/mcp/.
FOUNDRY_HOSTING_ENVIRONMENT When set, uses Foundry Toolbox instead of the standalone GitHub MCP client.

Concept / placeholder

This sample is not wired to real Azure resources by default. You supply the AI Gateway, storage, and any deployment resources.

Credits

Credits to the authors of the Foundry Hosted Agent sample at Azure-Samples/simple-foundry-hosted-agent-python-aigateway.

Issues