Using Claude in VS Code to Build a Custom Connector With Fivetran’s Connector SDK
This tutorial demonstrates how to build a custom Fivetran connector using the Connector SDK and Claude AI in Visual Studio Code. It explains how to create instructions for the AI agent, generate the connector files, debug, verify the output locally, and finally deploy the custom connector to Fivetran.
For prerequisites and best practices, see our Building a Custom Connector With VS Code and Claude AI documentation.
The tutorial is based on our FDA Drug API Connector Tutorial.
How to build a custom Fivetran connector with VS Code and Claude AI
The sections below provide high-level step-by-step instructions on how to build a custom connector using Connector SDK and Claude AI.
For detailed instructions, see our video tutorial and follow the links for additional educational resources.
Prerequisites
Make sure the following tools and setup steps are in place before starting to build a custom Fivetran connector with Claude AI and VS Code:
- Connector SDK installed (see How to Install Fivetran Connector SDK for detailed instructions)
- DuckDB installed
- Visual Studio Code installed
- GitHub Copilot extension installed in VS Code
- GitHub Copilot Chat extension is also installed
- Edit with Copilot available in the Copilot Chat sidebar (Agent Mode)
- (Optional) API key stored as an environment variable
Organize the workspace and verify local tooling
Expand for details
Create a dedicated project folder and confirm local tools are ready.
Project layout example:
FDA_drug_vscode_claude/
agents.md # system instructions pasted from the public repo
connector.py # added later by Claude
configuration.json # added later by Claude
requirements.txt # added later by Claude
README.md # added later by Claude
notes.txt # your API context: auth, endpoints, examples
For more details, see our Project Structure best practices documentation.
Suggested checks before you start prompting:
- Run
fivetran --version
in the VS Code terminal to confirm Connector SDK is on the path. - Run
python --version
to confirm your interpreter is available to the terminal inside VS Code. - If your source needs credentials, export an environment variable for the API key using your shell’s syntax. See our environment variable documentation for more details.
Prepare system instructions and context in VS Code
Watch this tutorial's segment on YouTube (00:00 - 02:08)
Expand for details
Set up the instruction system Copilot will use to guide Claude.
i. Click the Copilot Chat gear icon, choose Instructions, and create a new instruction file named
agents.md
.ii. Paste in the content of
ai_and_connector_sdk/agents.md
from the Fivetran public repository.iii. Add the template connector file
template_example_connector/connector.py
as an additional instruction reference.Create a project folder and add a context file named
notes.txt
that includes:- Authentication notes and whether an API key is optional
- API overview, endpoint names, base URLs, and any query parameters
- Example requests and sample response snippets from the OpenFDA Drug API
These files provide the AI model with concrete API context and a reference implementation for Connector SDK conventions.
Create the structured Claude prompt
Watch this tutorial's segment on YouTube (02:08 - 05:35)
Expand for details
Author a three-part prompt in Copilot Chat using Edit with Copilot.
- Source and intent:
- Target the OpenFDA Drug API endpoints to replicate.
- Point the model to
#file:notes.txt
for concrete query examples and response shapes.
- Functional behavior and constraints:
- Upsert only the first 10 results per endpoint by default to conserve quota during testing.
- Exit gracefully after a short run and include clear comments and strategic logging.
- Default to no API key required, while supporting an optional key via the configuration file.
- Ensure all configuration values are strings and define only primary keys so Fivetran can infer the rest.
- Allow the model to test queries first to validate endpoint behavior before writing code.
- Instruction references and output location:
- Follow best practices from
#file:agents.md
. - Use the template structure from the added
connector.py
reference. - Write generated files into the current project folder.
- Follow best practices from
Optional prompt you can adapt:
Create a Fivetran Connector SDK solution for the OpenFDA Drug API. Use the endpoint details and examples in `#file:notes.txt`. Default to no API key, but allow an optional key in `configuration.json`. Upsert the first 10 records per endpoint, then exit gracefully with logging and comments. Define only primary keys; all config values should be strings. Follow the guidance in `#file:agents.md` and mirror the structure of the template connector. Write files into this folder: `connector.py`, `configuration.json`, `requirements.txt`, `README.md`.
Generate connector files with Claude
Watch this tutorial's segment on YouTube (05:35 - 06:28)
Expand for details
- Make sure the Agent is enabled and Claude Sonnet 3.7 model is selected.
- Ask Copilot to create the full set of SDK files. Claude typically proposes a plan and then creates files in sequence. Files to expect:
connector.py
containing discover and sync logic, request helpers, loggingrequirements.txt
listingfivetran_sdk
and HTTP dependenciesconfiguration.json
with string-typed config values, plus optional API keyREADME.md
summarizing what the connector does and how to run it
- Accept the proposed edits in VS Code and confirm the files appear in the project folder. If any file is missing, ask Copilot to add it explicitly.
Run fivetran debug
and iterate on fixes
Watch this tutorial's segment on YouTube (06:28 - 08:12)
Expand for details
If your source requires credentials, set the API key as an environment variable before running debug
.
From the integrated terminal in VS Code, ask Copilot to execute:
fivetran debug connector.py --config configuration.json
See the Troubleshooting section for common errors encountered during debug and how to resolve them. Rerun until the summary shows a small test batch of upserts, a checkpoint, and any required schema change events.
Typical first-run issues and how Copilot addresses them:
- Date range errors causing empty or 404 responses. Copilot adjusts the lookback logic in code or config and retries.
- Field mismatches or unexpected shapes. Copilot updates the schema mapping and record emit logic.
- Pagination quirks. Copilot inspects response metadata and amends the loop conditions.
Rerun until the summary shows a small test batch of upserts, a checkpoint, and any required schema change events.
Inspect local output using DuckDB
Watch this tutorial's segment on YouTube (08:12 - 09:54)
Expand for details
Install and configure DuckDB to review the contents of the generated warehouse.db
file. See our Working with DuckDB documentation for more details.
Ask Copilot to open and review the warehouse.db
produced by the debug run. Have it show representative rows from each replicated table, summarize row counts and key fields, and call out any endpoints that are not yet represented.
If Copilot identifies gaps, use its observations to drive the next editing pass in connector.py
and configuration.json
.
Fix endpoint gaps and retest (Optional)
Watch this tutorial's segment on YouTube (09:54 - 14:05)
Expand for details
If a specific endpoint such as drug shortages fails to replicate:
- Provide example requests and field notes for that endpoint from the API documentation.
- Ask Copilot to test a request to confirm the correct query shape, then update the connector code accordingly.
- Claude will run the debug command again and confirm that the table for that endpoint now appears and contains rows.
Repeat this loop until all endpoints of interest are covered and validated locally.
Pre-deployment verification in Copilot
Watch this tutorial's segment on YouTube (14:05 - 15:42)
Expand for details
- Ask Copilot to verify the connector's readiness by querying the local
warehouse.db
for each replicated table. Request the following:- A list of all tables created by the debug run
- Row counts per table and identification of primary keys
- Sample rows per table to confirm expected fields
- If Copilot encounters an error while previewing a table (for example, selecting a non-existent column in a table), have it correct the query and, if needed, update
connector.py
logic for that endpoint. Copilot re-runsfivetran debug
when fixes are applied, then re-checks the tables until all targeted endpoints are present and populated.
Deploy the connector to Fivetran
Watch this tutorial's segment on YouTube (15:42 - 17:14)
Expand for details
- Request Copilot to deploy the connector to Fivetran using the following command:
fivetran deploy connector.py
- Provide the prompts in the terminal when asked:
- Destination name such as
csg_auto_test
- Connection name such as
FDA drug video
- API key (stored as an environment variable)
- Configuration path, which is the
configuration.json
in your project root
- Destination name such as
- When deployment succeeds, follow the returned link to the new connector in the Fivetran dashboard.
- Open the new connector page and start the initial sync.
Quality checklist before publishing
Expand for details
- Project contains the four generated files plus
notes.txt
andagents.md
- Debug run completes with a small test batch and emits consistent schema
- DuckDB review shows tables and keys populated for each endpoint
- Deployment to the intended destination succeeds and the connection link opens
- Initial sync completes without errors in the Fivetran dashboard
Recap
Expand for details
- You configured Copilot in VS Code with instruction files and API context
- Created a structured three‑part prompt aligned to the OpenFDA Drug API.
- Generated the connector files:
connector.py
,configuration.json
,requirements.txt
,README.md
. - Ran
fivetran debug
, resolve errors, and iterated to a clean test run. - Inspected the local
warehouse.db
with DuckDB and verified tables, keys, and row counts. - Closed gaps for any failing endpoints by enriching
notes.txt
and refiningconnector.py
. - Prepared the configuration for deployment and validated string‑typed values.
- Deployed the connector with
fivetran deploy
and opened it in the Fivetran dashboard. - Started the initial sync and confirmed the schema and data in the destination.
Troubleshooting
Expand for details
The issues below are drawn from the VS Code flow in the video transcript. Use them to keep the main steps clean while still capturing practical fixes.
Empty results or 404 errors after first debug run
- Symptom: responses are empty or the API returns 404.
- Likely cause: date range or query filters are too strict for the selected endpoint.
- Fix: loosen or remove the initial lookback window in
configuration.json
, or adjust query parameters inconnector.py
. Keep the test limit at 10. - Verify: rerun
fivetran debug
and confirm rows are emitted.
Field mismatches or schema errors
- Symptom: KeyError, missing field, or schema change events that repeat.
- Likely cause: response shape differs by endpoint or across pages.
- Fix: use safe accessors (for example,
dict.get
), flatten nested objects consistently, and declare only primary keys. Bump the local schema version if needed so changes are applied cleanly. - Verify: debug shows stable upserts without repeated schema changes.
Pagination only retrieves one page or duplicates rows
- Symptom: only a small subset of records appears, or duplicates are emitted.
- Likely cause: missing next-page handling, incorrect offset/limit logic, or not honoring continuation tokens.
- Fix: inspect response metadata for next links or cursors; update the loop to request subsequent pages; deduplicate by primary key when emitting.
- Verify: upsert counts increase across pages and duplicates disappear.
Endpoint table missing
- Symptom: an expected table is not created in
warehouse.db
. - Likely cause: endpoint not included in
configuration.json
or not wired inconnector.py
. - Fix: add the endpoint to config and map it to a handler in
connector.py
; include it in the discover schema. - Verify: rerun debug and confirm the table appears with rows.
Wrong working directory during CLI commands
- Symptom: CLI cannot find
connector.py
orconfiguration.json
. - Likely cause: running commands from a parent folder.
- Fix: change directory to the project root before running CLI.
- Verify: CLI starts and references the correct files.
Missing or unset API key when needed
- Symptom: HTTP 401 or 403.
- Likely cause: API requires a key, but the environment variable is unset.
- Fix: export the key as an environment variable and read it in
configuration.json
. See the environment variable guide. - Verify: authenticated requests succeed and records are emitted.
Rate limiting or HTTP 429
- Symptom: intermittent failures with 429 status.
- Likely cause: too many requests during testing.
- Fix: keep the test limit at 10, add small sleeps/backoff, and respect server rate limits.
- Verify: stable runs without 429 after adjustments.
warehouse.db
not created
- Symptom: no local database after debug.
- Likely cause: debug run failed early or the output path is incorrect.
- Fix: fix the failing error first; ensure the default output location is used or configured correctly.
- Verify: file appears in the project and opens in DuckDB.
DuckDB cannot open the file
- Symptom: error opening
warehouse.db
. - Likely cause: DuckDB not installed or wrong path.
- Fix: install DuckDB and provide the correct path to the db file; re-run debug if necessary.
- Verify: tables list successfully and rows are queryable.
Deployment prompts fail or are incomplete
- Symptom: deploy exits asking for destination, connection name, or config path.
- Likely cause: missing inputs.
- Fix: provide destination name, a clear connection name, and the
configuration.json
path. - Verify: CLI returns a connector URL and the page opens in Fivetran.
Agent edits the wrong folder
- Symptom: files are created or modified outside the project.
- Likely cause: workspace scope confusion.
- Fix: pin the project folder, point the agent to local files with
#file:
references, and confirm paths before accepting edits. - Verify: expected files update in the intended directory.