Sparkflows Q&A: SFTP, Python, Agents, MCP, RAG and More
We set up a Sparkflows sandbox for a client and while working on it they came up with a bunch of questions. Sharing the general ones here with answers, so everyone can refer to it when similar questions come up.
Context: The client is building an agent that reads a source-to-target mapping (Excel) and fixed-width source files from SFTP, then generates Fivetran Connector SDK code that loads the data into a target table. Some answers also cover doing the same load natively in Sparkflows, so they can compare the two.
Data and connectivity
1. Landing SFTP files for Read Flat File
Read Flat File reads from a path rather than from SFTP. What’s the usual pattern for landing SFTP files somewhere it can read them? Do the SFTP / SFTP Upload nodes handle that copy, and where should the files land?
Yes, the SFTP node does the copy. It copies files from the SFTP server to a target path as they are. It doesn’t read them into a dataset.
- The target can be a folder on the Spark server, HDFS, S3 (
s3://), GCS (gs://) or ADLS (abfs://). On a cluster, use HDFS or cloud storage so every node can read the files. - To copy a whole folder, end the remote path with
/or use a pattern such as/in/*.txt. - SFTP Upload goes the other way, from your storage to the SFTP server, so you don’t need it here.
The usual pattern is a Pipeline with two workflows that run one after the other:
- Workflow 1: SFTP copies the files to a landing folder, for example
/data/landing/sftp/. - Workflow 2: Read Flat File reads from that folder.
2. Read Flat File schema example
Could you share a working Read Flat File schema file with a matching sample data file?
The schema file is a CSV with a header row. Its columns are, in order: field name, data type, default value and length.
customer_schema.csv
fieldname,datatype,defaultValue,length
id,int,0,5
name,string,,10
city,string,NA,8
amount,double,0.0,8
customers.txt (fixed width, 31 characters per line)
00001John SmithBoston 00120.50
00002Jane Doe Chicago 00099.99
00003Raj Patel 00010.00
Node settings:
- Input Data Path: the path to
customers.txt - SchemaPath: the path to
customer_schema.csv - File Type:
fixed-length - Add Input File Name:
false - Schema: add the four columns (
idint,namestring,citystring,amountdouble) so the next nodes can see them.
Good to know:
- The fourth column is the field length, not a start or end position. Start positions are worked out in order.
- Supported types: int, long, double, float, boolean and string.
- A blank field gets its default value. In the sample, row 3’s city becomes
NA. - Spaces that pad text values are kept. Trim them in a later step if needed.
- For delimited files, set File Type to comma, tab, pipe or semicolon. The data file has no header row, the schema needs one row per column, and the length column can be left empty.
- Use this node in a Spark workflow.
3. SFTP → Python → table
The SFTP nodes only exist in Spark workflows and the Python nodes only in PySpark. For a flow like “read from SFTP, process in Python, load to a table”, how would you design it?
Use a Pipeline that runs two workflows in order. This is the native way to do the load in Sparkflows.
- Spark workflow: SFTP copies the files to a landing folder (HDFS, S3 or a shared path).
- PySpark workflow: Read CSV (from the landing folder) → PySpark node (your Python logic) → Save JDBC (or Save Delta) to write the table.
Another option is a single PySpark workflow where the PySpark node downloads the files with paramiko, processes them and saves the table. This needs paramiko installed first (see 4).
An agent’s Workflow Execution node can’t run this chain (see 5).
4. Python packages
For Run Python Code and Run Python File, which packages are available, and can we add our own (e.g. paramiko, openpyxl, fivetran-connector-sdk)?
Both nodes run your script as a separate Python process, using the PySpark engine’s Python environment. Imports aren’t restricted.
They don’t pass a dataset in or out. To work on a dataset, use the PySpark node instead.
- Already installed: pyspark 3.5.2, boto3, openai, langchain-community, mlflow, xgboost, prophet, psycopg2-binary, JayDeBeApi, openpyxl and xlrd.
- Not installed: paramiko and fivetran-connector-sdk.
To add packages, an admin installs them into that environment and then restarts the PySpark engine:
source <pyspark-engine-venv>/bin/activate
pip install paramiko fivetran-connector-sdk
You can see what’s installed under Administration → Diagnostics → Packages.
Agents
5. Workflow Execution
Which workflow types can it run, does the agent wait for the run and get the result back, what’s the maximum timeout, and can we chain two runs (e.g. Spark for the SFTP step, then PySpark for the Python step)?
- Workflow types: Polars workflows only. They run inside the agent engine. Spark and PySpark workflows show up in the list but can’t run here.
- Result: yes, the agent waits. It gets back the status, the row count and the values from the first output row. Later steps use them as
${<nodeId>.<column>}. - Timeout: 180 seconds by default, and 600 seconds at most.
- Retries: set Retry Attempts. A run that times out isn’t retried.
- Chaining: you can put two of these nodes in a row and pass single values, such as a file path, from the first run to the second. Whole datasets can’t be passed.
A Spark step followed by a PySpark step isn’t possible from an agent. Use a Pipeline for that (see 3).
6. Querying Postgres from an agent
What’s the recommended way for an agent to query a Postgres database: through a workflow, MCP, or something else?
Use the built-in PostgreSQL option:
- Create a PostgreSQL connection to your database.
- On the Agent node, click + Tool → PostgreSQL and pick the read operations: list tables, describe, get rows, count. These run without approval.
- For a fixed query, add an App Action node set to PostgreSQL → Query → run with your SQL. You can use values from earlier steps, for example
${1.fields.id}.
Other options are a Postgres MCP server (see 7), or Workflow Execution with a Polars workflow that reads the table.
7. MCP
Does “Add MCP Server” need Create Connection rights, and which transports are supported (HTTP, SSE, stdio)?
- Rights: adding an MCP server to an agent only needs edit access to the agent. Creating the MCP connection needs the Manage connections permission. By default only the Admin role has it.
- Transport: HTTP only (Streamable HTTP). stdio and older SSE-only servers aren’t supported.
- Auth: none, or an API token, which is sent as a Bearer token.
To set one up:
- Go to Connections → Add Connection and choose type MCP.
- Enter the server URL and the token, click Test Connection, then save.
- On the Agent node, open the MCP Registry tab → Add MCP Server → pick the connection → Fetch Tools → select the tools you want.
The Sparkflows server needs network access to the MCP server URL.
8. File upload from an agent
The REST API Client has no multipart option. Can we upload a file? Deploying a Fivetran SDK connector needs a package upload.
Not with the REST API Client. It only sends text bodies (JSON, form or plain text).
Use a Code node (Python) instead. requests is installed:
def main(items, inputs, outputs):
import requests
with open("/path/connector.zip", "rb") as f:
r = requests.post("https://api.example.com/upload",
headers={"Authorization": "Bearer <token>"},
files={"file": f}, timeout=300)
return [{"status": r.status_code, "body": r.text}]
Keep the node’s timeout at 600 seconds or less.
For Fivetran, the SDK uploads the package itself. The simplest route is to run its deploy command from a Python node where the SDK is installed (see 4).
9. Skills Registry
Is there a sample skill file or an expected .md format, can skills include code or tool calls, and who is allowed to publish to the Skills Registry?
A skill is a Markdown file (.md, up to 2 MB). It has an optional header with a name and description, followed by the instructions:
refund-policy.md
---
name: refund-policy
description: Official refund rules. Use for refund or return questions.
---
# Refund policy
1. Unused items: full refund within 30 days.
2. Anything else: escalate to a person.
- Samples come with the product in
data/Agentic_AI/AgenticAI-Intermediate/skills/. - Code and tools: a skill can’t run code. It can declare tools (REST, MCP or workflow) in a
## Toolssection.currency-conversion.mdin the samples shows how. - How it’s used: the agent sees each selected skill’s name and description, and loads the full text when it needs it.
- Scope: skills belong to a project, not to all projects. Any agent in that project can use them, and an edit changes the skill for all of those agents.
- Who can publish: anyone who can edit agents in that project. There’s no approval step, and deleting a skill is permanent.
10. Reading and writing files in an agent
What’s the intended way for an agent to read an input file (like a mapping Excel) and write output files (like generated code)?
Use the Read/Write Files node. For example:
Trigger → Read/Write Files (read the mapping Excel) → Agent (generate the code)
→ Read/Write Files (write the code) → Output
- Read: Mode = read, Read as = Excel, Path =
/data/mapping.xlsx, and pick the sheet. The rows go to the Agent. - Write: Mode = write, Format = Text, Path =
/data/out/connector.py, Text =${<agentNodeId>.analysis}. - Files must be on the agent server’s disk, or in S3, GCS or ADLS.
- Files are written in real runs. Canvas test runs skip writes.
11. RAG
The Context tab offers Pinecone or pgvector with text-embedding-3-small. Where do the vector database connection details live, how do we enable pgvector, how is the embedding model set up, and is there an example of building a knowledge base from documents?
- Connection details live in Connections. pgvector works with any PostgreSQL or JDBC connection, so you can pick your Postgres connection directly in the Context tab. Pinecone uses a Pinecone connection that holds the API key. The table or index name is set on the agent.
- pgvector: on the first run the agent turns on the extension and creates the table, if the database user is allowed to. If not, a DBA runs:
CREATE EXTENSION IF NOT EXISTS vector;
GRANT CREATE ON SCHEMA public TO <sparkflows_user>;
- Embeddings come from the Embeddings Endpoint Url on your Azure OpenAI connection. That URL decides which deployment is used. Make sure an embedding deployment (for example text-embedding-3-small) exists on your Azure OpenAI resource, then set:
https://<resource>.openai.azure.com/openai/deployments/<embedding-deployment>/embeddings?api-version=<version>
Two ways to build a knowledge base:
- In the Context tab, set Knowledge Source = document_path and point it at a folder of documents on the agent server (PDF, DOCX, TXT, MD, CSV or JSON). The documents are indexed when the agent runs, and later runs pick up only the changes.
- With a workflow: Document To Text → Text Embedder → Save PgVector DB. Then set the agent’s Knowledge Source to existing_vector_db.
For an example, see the Company Docs RAG Chatbot agent in the AgenticAI-Intermediate sample project.
12. Running agents by API, schedule or chat
Is there an API or webhook to run an agent with inputs and get the Output node’s result back? Can agents be scheduled, or published to users through Chat or Applications?
Yes. Start a run with inputs:
curl -X POST https://<host>/api/v1/agents/<agentId>/execute \
-H "token: <TOKEN>" -H "Content-Type: application/json" \
-d '{"inputs": {"userQuery": "Generate the connector"}}'
The response includes a runId. Then get the result:
curl https://<host>/api/v1/agents/<agentId>/runs/<runId>/status -H "token: <TOKEN>"
- The Output node’s values are under
node_outputs.<outputNodeId>.result. Fetch them within 5 minutes of the run finishing. - Calls use an API token. An admin turns on token generation, then you create a token.
- There’s no separate webhook URL. Other systems call the execute endpoint above.
- Schedule: yes, from the agent’s Schedules page (hourly, daily, weekly, monthly, every few minutes or cron, with a time zone).
- Chat: yes. Create a chat assistant backed by the agent (Create Assistant with Agents).
- Applications can’t run agents.
13. LLM limits, cost and data
What maximums can we use on the Agent Node (max tokens, timeout, tool rounds) for longer outputs like code generation, and are there any guidelines on cost or on what data we can send to the model?
- Max Tokens: the default is 8,000. You can set it up to the model’s own output limit: gpt-4o 16,384 · gpt-4.1 32,768 · gpt-5 128,000 · o-series 100,000. For code generation on gpt-4o, use about 16,000. If an answer hits the limit, it continues automatically.
- Tool rounds: there’s no hard limit. Keep 8 for most agents; use 15 to 25 for agents that research.
- Timeout: if a long answer times out, raise it.
- Cost: Sparkflows records tokens for every run (Agent Analytics), not money. Your cost is tokens × your model price. To keep it down, set Max Tokens no higher than you need, keep tool rounds low, and use a smaller model for simple steps.
- Data: prompts and data go only to the LLM endpoint in your connection, for example your Azure OpenAI. Add a Guardrails node before the model to block or mask PII (email, phone, card, SSN), prompt injection and banned words. Which data is allowed is set by your company policy.
Platform
14. Secrets
The REST API Client takes authentication as plain-text headers. What’s the recommended way to handle API keys so they aren’t visible in node settings or prompts? Can stored credentials be referenced from nodes?
Yes. Save the key once in Credentials and reference it in the node instead of pasting it.
- Open Credentials → Add Credentials. Pick or create a store (for example
fivetran), then add a key (for exampleapi_key) and its value. The value is stored encrypted. - In the REST API Client, set the header value to the reference:
Authorization=Bearer ${cs.fivetran.api_key}. - Sparkflows puts in the real value only when the agent runs. The node settings and exported agents show only the reference.
- The reference works in any node field or agent parameter.
- An agent can use keys from its own project and global keys, but not keys from other projects.
- Connector and MCP nodes already keep their keys in the connection.
- Header values aren’t sent to the model. Keep keys out of prompts and use references instead.
15. Moving agents and workflows
Can agents and workflows be exported, imported or version-controlled, so we can move them between environments?
Yes. Agents and workflows can be exported, imported and pushed to Git.
Connections and credentials stay in each environment, so create them in the target environment first.