Would it be possible to construct a working spacecraft using only materials extracted from the lunar surface? If not, what materials would we have to be ferried from Earth for this purpose?
Short answer: Yes, it is certainly possible.
Long answer: As has been noted before, there are abundances of metals. Although you can not really find large quantities of other important classes of substances such as hydrocarbons, you can actually find a lot of their chemical components (elements) contained in a number of minerals on the Lunar surface. So the question boils down to how to extract and process them. Then, the question should be referred to mineralogy and chemistry ...
There is a wonderful book about this topic, edited by Viorel Badescu and released in 2012: "Moon: Prospective Energy and Material Resources".
According to a couple of sources, such as space.com and Wikipedia, the Moon has an abundance of silicon, iron, aluminum, and titanium. The potential for other materials from millions of years of asteroids and comets suggests all the necessary building blocks for the hull and structure of the ship should be there. Helium-3 is also thought to be more abundant on the Moon, making it a potential fuel source.
What the Moon doesn't have is hydrocarbons for making plastics and rubber. You might be able to create airtight seals and electrical circuits without these things. Not being an electrical engineer I don't know. All of the electronics I've seen make heavy use of plastics and rubber for enclosing circuitry and shielding wires.
Constructing a spacecraft will be a ghastly expense for everyone involved, and even more in a non-accommodating surface such as the Moon's. Building a space craft is challenging engineering.
As suggested before, the Moon has an abundance of silicon, iron, aluminum and titanium. But do remember that these are raw materials, which are not processed in any way. And the materials used on our spacecraft are sent to us machined with certain specifications.
To make that possible, we will need a whole support structure of secondary industries such as these to actually process the raw materials into usable materials. Without processing facilities, it's as good as not having resources.
Aspects such as these make such a task even more daunting and economically taxing. The same goes for electronics - they will need a lot of tiny but crucial parts for construction. And these can't be produced without the appropriate machinery or labor (again economically, not preferable) On the other hand, if you were talking just about just the materials, then yes, you will find the above mentioned materials, but you will also be needing polymers of different kinds which I don't believe have been found.
Yes the Moon has most of the building block materials but without the helping industries such as mining, purification, molding, etc., you cannot have your parts ready for the spacecraft. I also think that even if we send everything from Earth to the Moon just to see if we can successfully assemble those parts it would be very very difficult since we don't have facilities over there.