You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 804244b
Browse filesBrowse the repository at this point in the historyBrowse files
This sample exposes the live repo data fetcher as an Azure Functions MCP extension tool and can consume that same Functions-hosted MCP service from the Copilot SDK.
4
+
5
+
The full Azure Functions tutorial belongs in Microsoft Learn. Start with [Tutorial: Host an MCP server on Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-mcp-tutorial), then use these sample-specific notes to see how the pieces map into this repo.
6
+
7
+
## Expose a Functions MCP tool
8
+
9
+
The repo digest data fetcher is exposed from [`function_app.py`](function_app.py) with the Python v2 Functions programming model:
10
+
11
+
```python
12
+
@app.mcp_tool()
13
+
@app.mcp_tool_property(
14
+
arg_name="repository",
15
+
description="Public GitHub repository in owner/name format.",
Remote endpoints require the `mcp_extension` system key unless `host.json` is configured for anonymous webhook authorization. Get the deployed key with:
35
+
36
+
```bash
37
+
az functionapp keys list \
38
+
--resource-group <resource-group> \
39
+
--name <function-app-name> \
40
+
--query systemKeys.mcp_extension \
41
+
--output tsv
42
+
```
43
+
44
+
## Consume the Functions MCP service from Copilot SDK
45
+
46
+
Pass the Functions MCP endpoint as a remote HTTP MCP server when creating a Copilot SDK session:
export MCP_EXTENSION_KEY="<mcp_extension system key>"
72
+
```
73
+
74
+
When `COPILOT_MCP_SERVER_URL` is set, `function_app.py` passes the MCP server into `CopilotClient.create_session` and asks the model to call `get_repo_digest_context` for live GitHub data. If `COPILOT_MCP_SERVER_URL` is not set, the sample falls back to fetching public GitHub REST data directly before sending the prompt to the model.
75
+
76
+
## References
77
+
78
+
-[Tutorial: Host an MCP server on Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-mcp-tutorial)
79
+
-[Model context protocol bindings for Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-mcp)
80
+
-[MCP tool trigger for Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-mcp-tool-trigger)
81
+
-[Using MCP servers with the GitHub Copilot SDK](https://github.com/github/copilot-sdk/blob/main/docs/features/mcp.md)
A simple AI agent built with the GitHub Copilot SDK, running as an Azure Function.
3
+
A simple AI agent built with the GitHub Copilot SDK, running as an Azure Function. It creates live daily GitHub repository digests for recent pull requests, issues, and workflow failures. The default repository is `Azure/azure-functions-host`.
4
4
5
5
> Looking for [C#](https://github.com/Azure-Samples/simple-agent-functions-dotnet) or [TypeScript](https://github.com/Azure-Samples/simple-agent-functions-typescript)?
-[Azurite](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite) for local Azure Functions storage
11
12
-[Azure Developer CLI (azd)](https://aka.ms/azd-install) (only needed for deploying Microsoft Foundry resources)
12
13
- Access to an AI model via one of:
13
-
-**GitHub Copilot subscription**— models are available automatically
14
-
-**Bring Your Own Key (BYOK)**— use an API key from [Microsoft Foundry](https://ai.azure.com) (see [BYOK docs](https://github.com/github/copilot-sdk/blob/main/docs/auth/byok.md))
14
+
-**GitHub Copilot subscription**- models are available automatically
15
+
-**Bring Your Own Key (BYOK)**- use an API key from [Microsoft Foundry](https://ai.azure.com) (see [BYOK docs](https://github.com/github/copilot-sdk/blob/main/docs/auth/byok.md))
15
16
16
17
## Quickstart
17
18
@@ -22,26 +23,30 @@ A simple AI agent built with the GitHub Copilot SDK, running as an Azure Functio
curl -X POST http://localhost:7071/api/ask -d "what are the laws"
48
+
curl -X POST http://localhost:7071/api/ask \
49
+
-d "Create a concise daily repo digest for Azure/azure-functions-host."
45
50
```
46
51
47
52
To chat with a deployed instance, grab the URL and function key from your `azd` environment:
@@ -58,10 +63,21 @@ A simple AI agent built with the GitHub Copilot SDK, running as an Azure Functio
58
63
59
64
## Source Code
60
65
61
-
The agent logic is in [`function_app.py`](function_app.py). It creates a `CopilotClient`, configures a session with a system message (Asimov's Three Laws of Robotics), and exposes an HTTP endpoint (`/api/ask`) that accepts a prompt and returns the agent's response.
66
+
The agent logic is in [`function_app.py`](function_app.py). It creates a `CopilotClient`, fetches live public GitHub data through REST APIs, and asks the model to produce a concise daily digest. The sample keeps the Azure Functions hosting model from this repo and exposes:
67
+
68
+
- An HTTP endpoint at `/api/ask` for chat or API requests.
69
+
- A timer-triggered function named `daily_repo_digest` that runs the digest at 9 AM Pacific.
62
70
63
71
[`chat.py`](chat.py) is a lightweight console client that POSTs messages to the function in a loop, giving you an interactive chat experience. It defaults to `http://localhost:7071` but can be pointed at a deployed instance via the `AGENT_URL` environment variable.
64
72
73
+
Ask for a digest with an optional public repo such as `Azure/azure-functions-host`. If you omit the repo, the agent uses `Azure/azure-functions-host` by default. Set `GITHUB_REPOSITORY` to change the default repository. Set `GITHUB_TOKEN` only if you want higher public GitHub API rate limits.
74
+
75
+
Local development uses [`pyproject.toml`](pyproject.toml) with `uv sync` and `uv run`. [`requirements.txt`](requirements.txt) is kept for Azure Functions packaging and should stay aligned with the dependencies in `pyproject.toml`.
76
+
77
+
## Daily Schedule
78
+
79
+
The timer trigger uses the Azure Functions NCRONTAB schedule `0 0 16,17 * * *`. Azure Functions timer schedules run in UTC for this Linux Functions sample, so the function wakes at both possible 9 AM Pacific UTC offsets and only creates a digest when the current `America/Los_Angeles` hour is 9. This keeps the sample aligned with Pacific daylight and standard time without adding a separate scheduler service.
80
+
65
81
## Deploy Microsoft Foundry Resources
66
82
67
83
If you prefer to use your own models via BYOK and don't already have a Microsoft Foundry project with a model deployed:
- If you ran `azd up`, the endpoint is already in your environment — run`azd env get-values | grep AZURE_OPENAI_ENDPOINT`
96
-
- For the API key, go to [Azure Portal](https://portal.azure.com) → your AI Services resource → **Keys and Endpoint** → select the **Azure OpenAI** tab
111
+
- If you ran `azd up`, the endpoint is already in your environment. Run`azd env get-values | grep AZURE_OPENAI_ENDPOINT`
112
+
- For the API key, go to [Azure Portal](https://portal.azure.com), your AI Services resource, **Keys and Endpoint**, then select the **Azure OpenAI** tab
97
113
- Or find both in the [Microsoft Foundry portal](https://ai.azure.com) under your project settings
98
114
99
115
See the [BYOK docs](https://github.com/github/copilot-sdk/blob/main/docs/auth/byok.md) for details.
100
116
117
+
## Next steps
118
+
119
+
- Add tools and data sources with Azure Functions custom bindings, Python helpers, or MCP integration: [MCP extension notes for this sample](MCP-extension-notes.md), [Tutorial: Host an MCP server on Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-mcp-tutorial), and [connect MCP server endpoints to Foundry agents](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/model-context-protocol).
0 commit comments