IR
irwinrodriguez.dev
Back to docs

Quick Start

Step 1: Verify the Broker is running

The FoxAgent installer already configured the Broker as a Windows service with automatic start. To verify it's running:

# In PowerShell or CMD:
sc query FoxAgentBroker

# You should see: STATE: RUNNING

If the service is not running, you can start it from the Windows Services console (services.msc) or with the command:

# Start the service manually:
net start FoxAgentBroker

Step 2: Connect your VFP application

In your VFP application, add the following code at startup (for example, in your main program or in the Init event of your main form):

* FoxAgent - Conexión del agente VFP
LOCAL loBridge
loBridge = CREATEOBJECT("FoxAgent.Bridge")

* 1. Establecer instancia VFP (ANTES de Connect)
loBridge.SetInstance(_VFP)

* 2. Configurar carpeta de herramientas personalizadas (UDTs)
*    Esta carpeta contiene tus herramientas que la IA podrá invocar
loBridge.SetToolsFolder("C:\MiProyecto\Tools")

* 3. Conectar al Broker
*    Parámetros: (ID único, nombre descriptivo, rol 0-3)
loBridge.Connect("mi-app-001", "Mi Aplicacion VFP", 3)

* El Bridge mantiene la conexión con heartbeats automáticos
* No necesitas llamar Heartbeat() manualmente

* IMPORTANTE: Mantén loBridge vivo mientras la app esté corriendo
* No lo liberes con loBridge = .NULL. hasta el cierre
Important: SetToolsFolder The SetToolsFolder() call is where FoxAgent shows its true value. The custom tools (UDTs) you place in that folder will be automatically discovered and made available to your AI agent. See the configuration section to learn how to create UDTs.

Complete example

Here's a complete example you can use as a starting point:

* foxagent-init.prg - Inicialización de FoxAgent
* Coloca este archivo en tu proyecto y llámalo al inicio de tu app

LPARAMETERS tcAppId, tcAppName

* Valores por defecto
IF EMPTY(tcAppId)
    tcAppId = "vfp-app-001"
ENDIF
IF EMPTY(tcAppName)
    tcAppName = "Mi Aplicación VFP"
ENDIF

* Crear el Bridge
PUBLIC goFoxAgent
goFoxAgent = CREATEOBJECT("FoxAgent.Bridge")

* Inicializar
goFoxAgent.SetInstance(_VFP)

* Configurar carpeta de UDTs (ajusta la ruta a tu proyecto)
LOCAL lcToolsPath
lcToolsPath = JUSTPATH(SYS(16,0)) + "\Tools"
IF DIRECTORY(lcToolsPath)
    goFoxAgent.SetToolsFolder(lcToolsPath)
ENDIF

* Conectar al Broker (rol 3 = Admin, acceso completo)
LOCAL llOk
llOk = goFoxAgent.Connect(tcAppId, tcAppName, 3)

IF llOk
    ? "FoxAgent conectado: " + tcAppName
    ? "Versión Bridge: " + goFoxAgent.GetVersion()
ELSE
    ? "Error conectando a FoxAgent. ¿Está corriendo el Broker?"
ENDIF

RETURN llOk

Step 3: Use with your AI agent

Once your VFP application is connected to the Broker, open your favorite AI agent and ask about the live instances:

  • Claude Desktop: Ask: "Show me the connected VFP instances"
  • OpenCode: Ask: "What FoxPro instances are active?"

Your AI agent will use FoxAgent's tools to list connected instances and can inspect variables, cursors, forms and more.

Examples of what you can ask

  • "Muestrame las variables publicas de mi aplicacion VFP"
  • "Que cursores estan abiertos y cuantos registros tienen?"
  • "Toma un screenshot de mi aplicacion"
  • "Ejecuta LIST MEMORY y muestrame el resultado"
  • "Cuales son los controles del formulario activo?"

Next steps