GitHub Copilot Tools in Agents - neerajk555/Github-Copilot-Workshop GitHub Wiki

Lesson Summary

In this lesson, we explored how to integrate GitHub Copilot Agents with tools and web search to unlock their full development capabilities. Without web search, agents rely on outdated SDKs. By enabling search and connecting to an MCP server, agents become significantly more powerful and accurate, especially for modern SDKs and API-driven tasks.


🧭 Step-by-Step Guide

  1. Launch GitHub Copilot Chat

    • Open VS Code
    • Start GitHub Copilot Chat
    • Select or create an agent
  2. Start Without Tools

    • Disable tools and web search
    • Request a task and observe outdated or incorrect code due to stale data
  3. Enable Web Search

    • Click the ⚙️ gear icon in Copilot Chat
    • Turn on Web Search
    • Optionally enable Multiple Web Searches
  4. Rerun the Prompt

    • Reissue the task (e.g., “use the latest OpenAI SDK…”)
    • Agent now retrieves accurate, current documentation/code
  5. Try Complex Tasks

    • Example:

      "Create a chatbot that provides currency conversion using the latest Forex API"

  6. Understand Tools vs MCP Server

    • Extensions provide basic tools like web search and code execution
    • MCP server unlocks custom tools and broader integrations

🌟 Example: Currency Conversion Agent

This example shows how Copilot (with web search enabled) creates a script to convert currencies using a live Forex API.

✅ Prompt

"Use the latest exchange rate API to create a Python script that converts currencies between USD, EUR, and JPY."

🔧 Script

python

import requests

def convert_currency(amount, from_currency, to_currency):
    url = f"https://api.exchangerate-api.com/v4/latest/{from_currency}"
    response = requests.get(url)
    data = response.json()

    if to_currency not in data['rates']:
        return f"Unsupported currency: {to_currency}"

    rate = data['rates'][to_currency]
    converted = round(amount * rate, 2)
    return f"{amount} {from_currency} = {converted} {to_currency}"

# Example usage
print(convert_currency(100, "USD", "EUR"))

🖥️ How to Run This Script in VS Code

  1. Prerequisites Install Python: https://www.python.org/downloads/ Install VS Code: https://code.visualstudio.com/ (Optional) Create and activate a virtual environment:

bash

python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
  1. Create the Script
  • Create a file: currency_converter.py
  • Paste the script above into the file
  1. Install Dependencies bash
pip install requests
  1. Run the Script bash
python currency_converter.py

Expected output:

100 USD = 91.23 EUR

🧠 Key Takeaways

  • Enable web search to ensure up-to-date SDKs and APIs
  • Use phrases like “use the latest version” to guide the agent
  • Use MCP server for broader and customizable tool integrations
  • Start small, then gradually test with search and tool enhancements

💡 Tips & Tricks

  • Always Enable Web Search:
  • Ensures you get the most recent tools, libraries, and SDKs.
  • Leverage MCP Server:
  • For advanced tasks like internal tool access or third-party API chaining.
  • Incremental Testing:
  • Start simple, validate outputs, then scale complexity with more tools/searches.

📦 What You Can Build Next

  • Telegram or Slack bots using live data
  • Dashboards that consume external APIs
  • Automation scripts for finance, weather, news, etc.
  • AI agents integrated with internal company APIs

Now you're ready to build smarter, more connected agents with GitHub Copilot!